| Howard Hinnant | 3257c98 | 2010-06-17 00:34:59 | [diff] [blame] | 1 | // -*- C++ -*- | 
|  | 2 | //===--------------------------- regex ------------------------------------===// | 
|  | 3 | // | 
|  | 4 | // The LLVM Compiler Infrastructure | 
|  | 5 | // | 
| Howard Hinnant | b64f8b0 | 2010-11-16 22:09:02 | [diff] [blame] | 6 | // This file is dual licensed under the MIT and the University of Illinois Open | 
|  | 7 | // Source Licenses. See LICENSE.TXT for details. | 
| Howard Hinnant | 3257c98 | 2010-06-17 00:34:59 | [diff] [blame] | 8 | // | 
|  | 9 | //===----------------------------------------------------------------------===// | 
|  | 10 |  | 
|  | 11 | #ifndef _LIBCPP_REGEX | 
|  | 12 | #define _LIBCPP_REGEX | 
|  | 13 |  | 
|  | 14 | /* | 
|  | 15 | regex synopsis | 
|  | 16 |  | 
|  | 17 | #include <initializer_list> | 
|  | 18 |  | 
|  | 19 | namespace std | 
|  | 20 | { | 
|  | 21 |  | 
|  | 22 | namespace regex_constants | 
|  | 23 | { | 
|  | 24 |  | 
|  | 25 | emum syntax_option_type | 
|  | 26 | { | 
|  | 27 | icase = unspecified, | 
|  | 28 | nosubs = unspecified, | 
|  | 29 | optimize = unspecified, | 
|  | 30 | collate = unspecified, | 
|  | 31 | ECMAScript = unspecified, | 
|  | 32 | basic = unspecified, | 
|  | 33 | extended = unspecified, | 
|  | 34 | awk = unspecified, | 
|  | 35 | grep = unspecified, | 
|  | 36 | egrep = unspecified | 
|  | 37 | }; | 
|  | 38 |  | 
|  | 39 | constexpr syntax_option_type operator~(syntax_option_type f); | 
|  | 40 | constexpr syntax_option_type operator&(syntax_option_type lhs, syntax_option_type rhs); | 
|  | 41 | constexpr syntax_option_type operator|(syntax_option_type lhs, syntax_option_type rhs); | 
|  | 42 |  | 
|  | 43 | enum match_flag_type | 
|  | 44 | { | 
|  | 45 | match_default = 0, | 
|  | 46 | match_not_bol = unspecified, | 
|  | 47 | match_not_eol = unspecified, | 
|  | 48 | match_not_bow = unspecified, | 
|  | 49 | match_not_eow = unspecified, | 
|  | 50 | match_any = unspecified, | 
|  | 51 | match_not_null = unspecified, | 
|  | 52 | match_continuous = unspecified, | 
|  | 53 | match_prev_avail = unspecified, | 
|  | 54 | format_default = 0, | 
|  | 55 | format_sed = unspecified, | 
|  | 56 | format_no_copy = unspecified, | 
|  | 57 | format_first_only = unspecified | 
|  | 58 | }; | 
|  | 59 |  | 
|  | 60 | constexpr match_flag_type operator~(match_flag_type f); | 
|  | 61 | constexpr match_flag_type operator&(match_flag_type lhs, match_flag_type rhs); | 
|  | 62 | constexpr match_flag_type operator|(match_flag_type lhs, match_flag_type rhs); | 
|  | 63 |  | 
|  | 64 | enum error_type | 
|  | 65 | { | 
|  | 66 | error_collate = unspecified, | 
|  | 67 | error_ctype = unspecified, | 
|  | 68 | error_escape = unspecified, | 
|  | 69 | error_backref = unspecified, | 
|  | 70 | error_brack = unspecified, | 
|  | 71 | error_paren = unspecified, | 
|  | 72 | error_brace = unspecified, | 
|  | 73 | error_badbrace = unspecified, | 
|  | 74 | error_range = unspecified, | 
|  | 75 | error_space = unspecified, | 
|  | 76 | error_badrepeat = unspecified, | 
|  | 77 | error_complexity = unspecified, | 
|  | 78 | error_stack = unspecified | 
|  | 79 | }; | 
|  | 80 |  | 
|  | 81 | } // regex_constants | 
|  | 82 |  | 
|  | 83 | class regex_error | 
|  | 84 | : public runtime_error | 
|  | 85 | { | 
|  | 86 | public: | 
|  | 87 | explicit regex_error(regex_constants::error_type ecode); | 
|  | 88 | regex_constants::error_type code() const; | 
|  | 89 | }; | 
|  | 90 |  | 
|  | 91 | template <class charT> | 
|  | 92 | struct regex_traits | 
|  | 93 | { | 
|  | 94 | public: | 
|  | 95 | typedef charT char_type; | 
|  | 96 | typedef basic_string<char_type> string_type; | 
|  | 97 | typedef locale locale_type; | 
|  | 98 | typedef /bitmask_type/ char_class_type; | 
|  | 99 |  | 
|  | 100 | regex_traits(); | 
|  | 101 |  | 
|  | 102 | static size_t length(const char_type* p); | 
|  | 103 | charT translate(charT c) const; | 
|  | 104 | charT translate_nocase(charT c) const; | 
|  | 105 | template <class ForwardIterator> | 
|  | 106 | string_type | 
|  | 107 | transform(ForwardIterator first, ForwardIterator last) const; | 
|  | 108 | template <class ForwardIterator> | 
|  | 109 | string_type | 
|  | 110 | transform_primary( ForwardIterator first, ForwardIterator last) const; | 
|  | 111 | template <class ForwardIterator> | 
|  | 112 | string_type | 
|  | 113 | lookup_collatename(ForwardIterator first, ForwardIterator last) const; | 
|  | 114 | template <class ForwardIterator> | 
|  | 115 | char_class_type | 
|  | 116 | lookup_classname(ForwardIterator first, ForwardIterator last, | 
|  | 117 | bool icase = false) const; | 
|  | 118 | bool isctype(charT c, char_class_type f) const; | 
|  | 119 | int value(charT ch, int radix) const; | 
|  | 120 | locale_type imbue(locale_type l); | 
|  | 121 | locale_type getloc()const; | 
|  | 122 | }; | 
|  | 123 |  | 
|  | 124 | template <class charT, class traits = regex_traits<charT>> | 
|  | 125 | class basic_regex | 
|  | 126 | { | 
|  | 127 | public: | 
|  | 128 | // types: | 
|  | 129 | typedef charT value_type; | 
|  | 130 | typedef regex_constants::syntax_option_type flag_type; | 
|  | 131 | typedef typename traits::locale_type locale_type; | 
|  | 132 |  | 
|  | 133 | // constants: | 
|  | 134 | static constexpr regex_constants::syntax_option_type icase = regex_constants::icase; | 
|  | 135 | static constexpr regex_constants::syntax_option_type nosubs = regex_constants::nosubs; | 
|  | 136 | static constexpr regex_constants::syntax_option_type optimize = regex_constants::optimize; | 
|  | 137 | static constexpr regex_constants::syntax_option_type collate = regex_constants::collate; | 
|  | 138 | static constexpr regex_constants::syntax_option_type ECMAScript = regex_constants::ECMAScript; | 
|  | 139 | static constexpr regex_constants::syntax_option_type basic = regex_constants::basic; | 
|  | 140 | static constexpr regex_constants::syntax_option_type extended = regex_constants::extended; | 
|  | 141 | static constexpr regex_constants::syntax_option_type awk = regex_constants::awk; | 
|  | 142 | static constexpr regex_constants::syntax_option_type grep = regex_constants::grep; | 
|  | 143 | static constexpr regex_constants::syntax_option_type egrep = regex_constants::egrep; | 
|  | 144 |  | 
|  | 145 | // construct/copy/destroy: | 
|  | 146 | basic_regex(); | 
|  | 147 | explicit basic_regex(const charT* p, flag_type f = regex_constants::ECMAScript); | 
|  | 148 | basic_regex(const charT* p, size_t len, flag_type f); | 
|  | 149 | basic_regex(const basic_regex&); | 
| Howard Hinnant | 46623a0 | 2012-07-21 01:31:58 | [diff] [blame] | 150 | basic_regex(basic_regex&&) noexcept; | 
| Howard Hinnant | 3257c98 | 2010-06-17 00:34:59 | [diff] [blame] | 151 | template <class ST, class SA> | 
|  | 152 | explicit basic_regex(const basic_string<charT, ST, SA>& p, | 
|  | 153 | flag_type f = regex_constants::ECMAScript); | 
|  | 154 | template <class ForwardIterator> | 
|  | 155 | basic_regex(ForwardIterator first, ForwardIterator last, | 
|  | 156 | flag_type f = regex_constants::ECMAScript); | 
|  | 157 | basic_regex(initializer_list<charT>, flag_type = regex_constants::ECMAScript); | 
|  | 158 |  | 
|  | 159 | ~basic_regex(); | 
|  | 160 |  | 
|  | 161 | basic_regex& operator=(const basic_regex&); | 
| Howard Hinnant | 46623a0 | 2012-07-21 01:31:58 | [diff] [blame] | 162 | basic_regex& operator=(basic_regex&&) noexcept; | 
| Howard Hinnant | 3257c98 | 2010-06-17 00:34:59 | [diff] [blame] | 163 | basic_regex& operator=(const charT* ptr); | 
|  | 164 | basic_regex& operator=(initializer_list<charT> il); | 
|  | 165 | template <class ST, class SA> | 
|  | 166 | basic_regex& operator=(const basic_string<charT, ST, SA>& p); | 
|  | 167 |  | 
|  | 168 | // assign: | 
|  | 169 | basic_regex& assign(const basic_regex& that); | 
| Howard Hinnant | 46623a0 | 2012-07-21 01:31:58 | [diff] [blame] | 170 | basic_regex& assign(basic_regex&& that) noexcept; | 
| Howard Hinnant | 3257c98 | 2010-06-17 00:34:59 | [diff] [blame] | 171 | basic_regex& assign(const charT* ptr, flag_type f = regex_constants::ECMAScript); | 
|  | 172 | basic_regex& assign(const charT* p, size_t len, flag_type f); | 
|  | 173 | template <class string_traits, class A> | 
|  | 174 | basic_regex& assign(const basic_string<charT, string_traits, A>& s, | 
|  | 175 | flag_type f = regex_constants::ECMAScript); | 
|  | 176 | template <class InputIterator> | 
|  | 177 | basic_regex& assign(InputIterator first, InputIterator last, | 
|  | 178 | flag_type f = regex_constants::ECMAScript); | 
|  | 179 | basic_regex& assign(initializer_list<charT>, flag_type = regex_constants::ECMAScript); | 
|  | 180 |  | 
|  | 181 | // const operations: | 
|  | 182 | unsigned mark_count() const; | 
|  | 183 | flag_type flags() const; | 
|  | 184 |  | 
|  | 185 | // locale: | 
|  | 186 | locale_type imbue(locale_type loc); | 
|  | 187 | locale_type getloc() const; | 
|  | 188 |  | 
|  | 189 | // swap: | 
|  | 190 | void swap(basic_regex&); | 
|  | 191 | }; | 
|  | 192 |  | 
|  | 193 | typedef basic_regex<char> regex; | 
|  | 194 | typedef basic_regex<wchar_t> wregex; | 
|  | 195 |  | 
|  | 196 | template <class charT, class traits> | 
|  | 197 | void swap(basic_regex<charT, traits>& e1, basic_regex<charT, traits>& e2); | 
|  | 198 |  | 
|  | 199 | template <class BidirectionalIterator> | 
|  | 200 | class sub_match | 
|  | 201 | : public pair<BidirectionalIterator, BidirectionalIterator> | 
|  | 202 | { | 
|  | 203 | public: | 
|  | 204 | typedef typename iterator_traits<BidirectionalIterator>::value_type value_type; | 
|  | 205 | typedef typename iterator_traits<BidirectionalIterator>::difference_type difference_type; | 
|  | 206 | typedef BidirectionalIterator iterator; | 
|  | 207 | typedef basic_string<value_type> string_type; | 
|  | 208 |  | 
|  | 209 | bool matched; | 
|  | 210 |  | 
| Howard Hinnant | 31aaf55 | 2010-12-08 21:07:55 | [diff] [blame] | 211 | constexpr sub_match(); | 
|  | 212 |  | 
| Howard Hinnant | 3257c98 | 2010-06-17 00:34:59 | [diff] [blame] | 213 | difference_type length() const; | 
|  | 214 | operator string_type() const; | 
|  | 215 | string_type str() const; | 
|  | 216 |  | 
|  | 217 | int compare(const sub_match& s) const; | 
|  | 218 | int compare(const string_type& s) const; | 
|  | 219 | int compare(const value_type* s) const; | 
|  | 220 | }; | 
|  | 221 |  | 
|  | 222 | typedef sub_match<const char*> csub_match; | 
|  | 223 | typedef sub_match<const wchar_t*> wcsub_match; | 
|  | 224 | typedef sub_match<string::const_iterator> ssub_match; | 
|  | 225 | typedef sub_match<wstring::const_iterator> wssub_match; | 
|  | 226 |  | 
|  | 227 | template <class BiIter> | 
|  | 228 | bool | 
|  | 229 | operator==(const sub_match<BiIter>& lhs, const sub_match<BiIter>& rhs); | 
|  | 230 |  | 
|  | 231 | template <class BiIter> | 
|  | 232 | bool | 
|  | 233 | operator!=(const sub_match<BiIter>& lhs, const sub_match<BiIter>& rhs); | 
|  | 234 |  | 
|  | 235 | template <class BiIter> | 
|  | 236 | bool | 
|  | 237 | operator<(const sub_match<BiIter>& lhs, const sub_match<BiIter>& rhs); | 
|  | 238 |  | 
|  | 239 | template <class BiIter> | 
|  | 240 | bool | 
|  | 241 | operator<=(const sub_match<BiIter>& lhs, const sub_match<BiIter>& rhs); | 
|  | 242 |  | 
|  | 243 | template <class BiIter> | 
|  | 244 | bool | 
|  | 245 | operator>=(const sub_match<BiIter>& lhs, const sub_match<BiIter>& rhs); | 
|  | 246 |  | 
|  | 247 | template <class BiIter> | 
|  | 248 | bool | 
|  | 249 | operator>(const sub_match<BiIter>& lhs, const sub_match<BiIter>& rhs); | 
|  | 250 |  | 
|  | 251 | template <class BiIter, class ST, class SA> | 
|  | 252 | bool | 
|  | 253 | operator==(const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& lhs, | 
|  | 254 | const sub_match<BiIter>& rhs); | 
|  | 255 |  | 
|  | 256 | template <class BiIter, class ST, class SA> | 
|  | 257 | bool | 
|  | 258 | operator!=(const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& lhs, | 
|  | 259 | const sub_match<BiIter>& rhs); | 
|  | 260 |  | 
|  | 261 | template <class BiIter, class ST, class SA> | 
|  | 262 | bool | 
|  | 263 | operator<(const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& lhs, | 
|  | 264 | const sub_match<BiIter>& rhs); | 
|  | 265 |  | 
|  | 266 | template <class BiIter, class ST, class SA> | 
|  | 267 | bool | 
|  | 268 | operator>(const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& lhs, | 
|  | 269 | const sub_match<BiIter>& rhs); | 
|  | 270 |  | 
|  | 271 | template <class BiIter, class ST, class SA> | 
|  | 272 | bool operator>=(const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& lhs, | 
|  | 273 | const sub_match<BiIter>& rhs); | 
|  | 274 |  | 
|  | 275 | template <class BiIter, class ST, class SA> | 
|  | 276 | bool | 
|  | 277 | operator<=(const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& lhs, | 
|  | 278 | const sub_match<BiIter>& rhs); | 
|  | 279 |  | 
|  | 280 | template <class BiIter, class ST, class SA> | 
|  | 281 | bool | 
|  | 282 | operator==(const sub_match<BiIter>& lhs, | 
|  | 283 | const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& rhs); | 
|  | 284 |  | 
|  | 285 | template <class BiIter, class ST, class SA> | 
|  | 286 | bool | 
|  | 287 | operator!=(const sub_match<BiIter>& lhs, | 
|  | 288 | const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& rhs); | 
|  | 289 |  | 
|  | 290 | template <class BiIter, class ST, class SA> | 
|  | 291 | bool | 
|  | 292 | operator<(const sub_match<BiIter>& lhs, | 
|  | 293 | const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& rhs); | 
|  | 294 |  | 
|  | 295 | template <class BiIter, class ST, class SA> | 
|  | 296 | bool operator>(const sub_match<BiIter>& lhs, | 
|  | 297 | const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& rhs); | 
|  | 298 |  | 
|  | 299 | template <class BiIter, class ST, class SA> | 
|  | 300 | bool | 
|  | 301 | operator>=(const sub_match<BiIter>& lhs, | 
|  | 302 | const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& rhs); | 
|  | 303 |  | 
|  | 304 | template <class BiIter, class ST, class SA> | 
|  | 305 | bool | 
|  | 306 | operator<=(const sub_match<BiIter>& lhs, | 
|  | 307 | const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& rhs); | 
|  | 308 |  | 
|  | 309 | template <class BiIter> | 
|  | 310 | bool | 
|  | 311 | operator==(typename iterator_traits<BiIter>::value_type const* lhs, | 
|  | 312 | const sub_match<BiIter>& rhs); | 
|  | 313 |  | 
|  | 314 | template <class BiIter> | 
|  | 315 | bool | 
|  | 316 | operator!=(typename iterator_traits<BiIter>::value_type const* lhs, | 
|  | 317 | const sub_match<BiIter>& rhs); | 
|  | 318 |  | 
|  | 319 | template <class BiIter> | 
|  | 320 | bool | 
|  | 321 | operator<(typename iterator_traits<BiIter>::value_type const* lhs, | 
|  | 322 | const sub_match<BiIter>& rhs); | 
|  | 323 |  | 
|  | 324 | template <class BiIter> | 
|  | 325 | bool | 
|  | 326 | operator>(typename iterator_traits<BiIter>::value_type const* lhs, | 
|  | 327 | const sub_match<BiIter>& rhs); | 
|  | 328 |  | 
|  | 329 | template <class BiIter> | 
|  | 330 | bool | 
|  | 331 | operator>=(typename iterator_traits<BiIter>::value_type const* lhs, | 
|  | 332 | const sub_match<BiIter>& rhs); | 
|  | 333 |  | 
|  | 334 | template <class BiIter> | 
|  | 335 | bool | 
|  | 336 | operator<=(typename iterator_traits<BiIter>::value_type const* lhs, | 
|  | 337 | const sub_match<BiIter>& rhs); | 
|  | 338 |  | 
|  | 339 | template <class BiIter> | 
|  | 340 | bool | 
|  | 341 | operator==(const sub_match<BiIter>& lhs, | 
|  | 342 | typename iterator_traits<BiIter>::value_type const* rhs); | 
|  | 343 |  | 
|  | 344 | template <class BiIter> | 
|  | 345 | bool | 
|  | 346 | operator!=(const sub_match<BiIter>& lhs, | 
|  | 347 | typename iterator_traits<BiIter>::value_type const* rhs); | 
|  | 348 |  | 
|  | 349 | template <class BiIter> | 
|  | 350 | bool | 
|  | 351 | operator<(const sub_match<BiIter>& lhs, | 
|  | 352 | typename iterator_traits<BiIter>::value_type const* rhs); | 
|  | 353 |  | 
|  | 354 | template <class BiIter> | 
|  | 355 | bool | 
|  | 356 | operator>(const sub_match<BiIter>& lhs, | 
|  | 357 | typename iterator_traits<BiIter>::value_type const* rhs); | 
|  | 358 |  | 
|  | 359 | template <class BiIter> | 
|  | 360 | bool | 
|  | 361 | operator>=(const sub_match<BiIter>& lhs, | 
|  | 362 | typename iterator_traits<BiIter>::value_type const* rhs); | 
|  | 363 |  | 
|  | 364 | template <class BiIter> | 
|  | 365 | bool | 
|  | 366 | operator<=(const sub_match<BiIter>& lhs, | 
|  | 367 | typename iterator_traits<BiIter>::value_type const* rhs); | 
|  | 368 |  | 
|  | 369 | template <class BiIter> | 
|  | 370 | bool | 
|  | 371 | operator==(typename iterator_traits<BiIter>::value_type const& lhs, | 
|  | 372 | const sub_match<BiIter>& rhs); | 
|  | 373 |  | 
|  | 374 | template <class BiIter> | 
|  | 375 | bool | 
|  | 376 | operator!=(typename iterator_traits<BiIter>::value_type const& lhs, | 
|  | 377 | const sub_match<BiIter>& rhs); | 
|  | 378 |  | 
|  | 379 | template <class BiIter> | 
|  | 380 | bool | 
|  | 381 | operator<(typename iterator_traits<BiIter>::value_type const& lhs, | 
|  | 382 | const sub_match<BiIter>& rhs); | 
|  | 383 |  | 
|  | 384 | template <class BiIter> | 
|  | 385 | bool | 
|  | 386 | operator>(typename iterator_traits<BiIter>::value_type const& lhs, | 
|  | 387 | const sub_match<BiIter>& rhs); | 
|  | 388 |  | 
|  | 389 | template <class BiIter> | 
|  | 390 | bool | 
|  | 391 | operator>=(typename iterator_traits<BiIter>::value_type const& lhs, | 
|  | 392 | const sub_match<BiIter>& rhs); | 
|  | 393 |  | 
|  | 394 | template <class BiIter> | 
|  | 395 | bool | 
|  | 396 | operator<=(typename iterator_traits<BiIter>::value_type const& lhs, | 
|  | 397 | const sub_match<BiIter>& rhs); | 
|  | 398 |  | 
|  | 399 | template <class BiIter> | 
|  | 400 | bool | 
|  | 401 | operator==(const sub_match<BiIter>& lhs, | 
|  | 402 | typename iterator_traits<BiIter>::value_type const& rhs); | 
|  | 403 |  | 
|  | 404 | template <class BiIter> | 
|  | 405 | bool | 
|  | 406 | operator!=(const sub_match<BiIter>& lhs, | 
|  | 407 | typename iterator_traits<BiIter>::value_type const& rhs); | 
|  | 408 |  | 
|  | 409 | template <class BiIter> | 
|  | 410 | bool | 
|  | 411 | operator<(const sub_match<BiIter>& lhs, | 
|  | 412 | typename iterator_traits<BiIter>::value_type const& rhs); | 
|  | 413 |  | 
|  | 414 | template <class BiIter> | 
|  | 415 | bool | 
|  | 416 | operator>(const sub_match<BiIter>& lhs, | 
|  | 417 | typename iterator_traits<BiIter>::value_type const& rhs); | 
|  | 418 |  | 
|  | 419 | template <class BiIter> | 
|  | 420 | bool | 
|  | 421 | operator>=(const sub_match<BiIter>& lhs, | 
|  | 422 | typename iterator_traits<BiIter>::value_type const& rhs); | 
|  | 423 |  | 
|  | 424 | template <class BiIter> | 
|  | 425 | bool | 
|  | 426 | operator<=(const sub_match<BiIter>& lhs, | 
|  | 427 | typename iterator_traits<BiIter>::value_type const& rhs); | 
|  | 428 |  | 
|  | 429 | template <class charT, class ST, class BiIter> | 
|  | 430 | basic_ostream<charT, ST>& | 
|  | 431 | operator<<(basic_ostream<charT, ST>& os, const sub_match<BiIter>& m); | 
|  | 432 |  | 
|  | 433 | template <class BidirectionalIterator, | 
|  | 434 | class Allocator = allocator<sub_match<BidirectionalIterator>>> | 
|  | 435 | class match_results | 
|  | 436 | { | 
|  | 437 | public: | 
|  | 438 | typedef sub_match<BidirectionalIterator> value_type; | 
|  | 439 | typedef const value_type& const_reference; | 
|  | 440 | typedef const_reference reference; | 
|  | 441 | typedef /implementation-defined/ const_iterator; | 
|  | 442 | typedef const_iterator iterator; | 
|  | 443 | typedef typename iterator_traits<BidirectionalIterator>::difference_type difference_type; | 
|  | 444 | typedef typename allocator_traits<Allocator>::size_type size_type; | 
|  | 445 | typedef Allocator allocator_type; | 
|  | 446 | typedef typename iterator_traits<BidirectionalIterator>::value_type char_type; | 
|  | 447 | typedef basic_string<char_type> string_type; | 
|  | 448 |  | 
|  | 449 | // construct/copy/destroy: | 
|  | 450 | explicit match_results(const Allocator& a = Allocator()); | 
|  | 451 | match_results(const match_results& m); | 
| Howard Hinnant | 46623a0 | 2012-07-21 01:31:58 | [diff] [blame] | 452 | match_results(match_results&& m) noexcept; | 
| Howard Hinnant | 3257c98 | 2010-06-17 00:34:59 | [diff] [blame] | 453 | match_results& operator=(const match_results& m); | 
|  | 454 | match_results& operator=(match_results&& m); | 
|  | 455 | ~match_results(); | 
|  | 456 |  | 
| Howard Hinnant | 31aaf55 | 2010-12-08 21:07:55 | [diff] [blame] | 457 | bool ready() const; | 
|  | 458 |  | 
| Howard Hinnant | 3257c98 | 2010-06-17 00:34:59 | [diff] [blame] | 459 | // size: | 
|  | 460 | size_type size() const; | 
|  | 461 | size_type max_size() const; | 
|  | 462 | bool empty() const; | 
|  | 463 |  | 
|  | 464 | // element access: | 
|  | 465 | difference_type length(size_type sub = 0) const; | 
|  | 466 | difference_type position(size_type sub = 0) const; | 
|  | 467 | string_type str(size_type sub = 0) const; | 
|  | 468 | const_reference operator[](size_type n) const; | 
|  | 469 |  | 
|  | 470 | const_reference prefix() const; | 
|  | 471 | const_reference suffix() const; | 
|  | 472 |  | 
|  | 473 | const_iterator begin() const; | 
|  | 474 | const_iterator end() const; | 
|  | 475 | const_iterator cbegin() const; | 
|  | 476 | const_iterator cend() const; | 
|  | 477 |  | 
|  | 478 | // format: | 
|  | 479 | template <class OutputIter> | 
|  | 480 | OutputIter | 
|  | 481 | format(OutputIter out, const char_type* fmt_first, | 
|  | 482 | const char_type* fmt_last, | 
|  | 483 | regex_constants::match_flag_type flags = regex_constants::format_default) const; | 
|  | 484 | template <class OutputIter, class ST, class SA> | 
|  | 485 | OutputIter | 
|  | 486 | format(OutputIter out, const basic_string<char_type, ST, SA>& fmt, | 
|  | 487 | regex_constants::match_flag_type flags = regex_constants::format_default) const; | 
|  | 488 | template <class ST, class SA> | 
|  | 489 | basic_string<char_type, ST, SA> | 
|  | 490 | format(const basic_string<char_type, ST, SA>& fmt, | 
|  | 491 | regex_constants::match_flag_type flags = regex_constants::format_default) const; | 
|  | 492 | string_type | 
|  | 493 | format(const char_type* fmt, | 
|  | 494 | regex_constants::match_flag_type flags = regex_constants::format_default) const; | 
|  | 495 |  | 
|  | 496 | // allocator: | 
|  | 497 | allocator_type get_allocator() const; | 
|  | 498 |  | 
|  | 499 | // swap: | 
|  | 500 | void swap(match_results& that); | 
|  | 501 | }; | 
|  | 502 |  | 
|  | 503 | typedef match_results<const char*> cmatch; | 
|  | 504 | typedef match_results<const wchar_t*> wcmatch; | 
|  | 505 | typedef match_results<string::const_iterator> smatch; | 
|  | 506 | typedef match_results<wstring::const_iterator> wsmatch; | 
|  | 507 |  | 
|  | 508 | template <class BidirectionalIterator, class Allocator> | 
|  | 509 | bool | 
|  | 510 | operator==(const match_results<BidirectionalIterator, Allocator>& m1, | 
|  | 511 | const match_results<BidirectionalIterator, Allocator>& m2); | 
|  | 512 |  | 
|  | 513 | template <class BidirectionalIterator, class Allocator> | 
|  | 514 | bool | 
|  | 515 | operator!=(const match_results<BidirectionalIterator, Allocator>& m1, | 
|  | 516 | const match_results<BidirectionalIterator, Allocator>& m2); | 
|  | 517 |  | 
|  | 518 | template <class BidirectionalIterator, class Allocator> | 
|  | 519 | void | 
|  | 520 | swap(match_results<BidirectionalIterator, Allocator>& m1, | 
|  | 521 | match_results<BidirectionalIterator, Allocator>& m2); | 
|  | 522 |  | 
|  | 523 | template <class BidirectionalIterator, class Allocator, class charT, class traits> | 
|  | 524 | bool | 
|  | 525 | regex_match(BidirectionalIterator first, BidirectionalIterator last, | 
|  | 526 | match_results<BidirectionalIterator, Allocator>& m, | 
|  | 527 | const basic_regex<charT, traits>& e, | 
|  | 528 | regex_constants::match_flag_type flags = regex_constants::match_default); | 
|  | 529 |  | 
|  | 530 | template <class BidirectionalIterator, class charT, class traits> | 
|  | 531 | bool | 
|  | 532 | regex_match(BidirectionalIterator first, BidirectionalIterator last, | 
|  | 533 | const basic_regex<charT, traits>& e, | 
|  | 534 | regex_constants::match_flag_type flags = regex_constants::match_default); | 
|  | 535 |  | 
|  | 536 | template <class charT, class Allocator, class traits> | 
|  | 537 | bool | 
|  | 538 | regex_match(const charT* str, match_results<const charT*, Allocator>& m, | 
|  | 539 | const basic_regex<charT, traits>& e, | 
|  | 540 | regex_constants::match_flag_type flags = regex_constants::match_default); | 
|  | 541 |  | 
|  | 542 | template <class ST, class SA, class Allocator, class charT, class traits> | 
|  | 543 | bool | 
|  | 544 | regex_match(const basic_string<charT, ST, SA>& s, | 
|  | 545 | match_results<typename basic_string<charT, ST, SA>::const_iterator, Allocator>& m, | 
|  | 546 | const basic_regex<charT, traits>& e, | 
|  | 547 | regex_constants::match_flag_type flags = regex_constants::match_default); | 
|  | 548 |  | 
|  | 549 | template <class charT, class traits> | 
|  | 550 | bool | 
|  | 551 | regex_match(const charT* str, const basic_regex<charT, traits>& e, | 
|  | 552 | regex_constants::match_flag_type flags = regex_constants::match_default); | 
|  | 553 |  | 
|  | 554 | template <class ST, class SA, class charT, class traits> | 
|  | 555 | bool | 
|  | 556 | regex_match(const basic_string<charT, ST, SA>& s, | 
|  | 557 | const basic_regex<charT, traits>& e, | 
|  | 558 | regex_constants::match_flag_type flags = regex_constants::match_default); | 
|  | 559 |  | 
|  | 560 | template <class BidirectionalIterator, class Allocator, class charT, class traits> | 
|  | 561 | bool | 
|  | 562 | regex_search(BidirectionalIterator first, BidirectionalIterator last, | 
|  | 563 | match_results<BidirectionalIterator, Allocator>& m, | 
|  | 564 | const basic_regex<charT, traits>& e, | 
|  | 565 | regex_constants::match_flag_type flags = regex_constants::match_default); | 
|  | 566 |  | 
|  | 567 | template <class BidirectionalIterator, class charT, class traits> | 
|  | 568 | bool | 
|  | 569 | regex_search(BidirectionalIterator first, BidirectionalIterator last, | 
|  | 570 | const basic_regex<charT, traits>& e, | 
|  | 571 | regex_constants::match_flag_type flags = regex_constants::match_default); | 
|  | 572 |  | 
|  | 573 | template <class charT, class Allocator, class traits> | 
|  | 574 | bool | 
|  | 575 | regex_search(const charT* str, match_results<const charT*, Allocator>& m, | 
|  | 576 | const basic_regex<charT, traits>& e, | 
|  | 577 | regex_constants::match_flag_type flags = regex_constants::match_default); | 
|  | 578 |  | 
|  | 579 | template <class charT, class traits> | 
|  | 580 | bool | 
|  | 581 | regex_search(const charT* str, const basic_regex<charT, traits>& e, | 
|  | 582 | regex_constants::match_flag_type flags = regex_constants::match_default); | 
|  | 583 |  | 
|  | 584 | template <class ST, class SA, class charT, class traits> | 
|  | 585 | bool | 
|  | 586 | regex_search(const basic_string<charT, ST, SA>& s, | 
|  | 587 | const basic_regex<charT, traits>& e, | 
|  | 588 | regex_constants::match_flag_type flags = regex_constants::match_default); | 
|  | 589 |  | 
|  | 590 | template <class ST, class SA, class Allocator, class charT, class traits> | 
|  | 591 | bool | 
|  | 592 | regex_search(const basic_string<charT, ST, SA>& s, | 
|  | 593 | match_results<typename basic_string<charT, ST, SA>::const_iterator, Allocator>& m, | 
|  | 594 | const basic_regex<charT, traits>& e, | 
|  | 595 | regex_constants::match_flag_type flags = regex_constants::match_default); | 
|  | 596 |  | 
|  | 597 | template <class OutputIterator, class BidirectionalIterator, | 
|  | 598 | class traits, class charT, class ST, class SA> | 
|  | 599 | OutputIterator | 
|  | 600 | regex_replace(OutputIterator out, | 
|  | 601 | BidirectionalIterator first, BidirectionalIterator last, | 
|  | 602 | const basic_regex<charT, traits>& e, | 
|  | 603 | const basic_string<charT, ST, SA>& fmt, | 
|  | 604 | regex_constants::match_flag_type flags = regex_constants::match_default); | 
|  | 605 |  | 
|  | 606 | template <class OutputIterator, class BidirectionalIterator, | 
|  | 607 | class traits, class charT> | 
|  | 608 | OutputIterator | 
|  | 609 | regex_replace(OutputIterator out, | 
|  | 610 | BidirectionalIterator first, BidirectionalIterator last, | 
|  | 611 | const basic_regex<charT, traits>& e, const charT* fmt, | 
|  | 612 | regex_constants::match_flag_type flags = regex_constants::match_default); | 
|  | 613 |  | 
|  | 614 | template <class traits, class charT, class ST, class SA, class FST, class FSA>> | 
|  | 615 | basic_string<charT, ST, SA> | 
|  | 616 | regex_replace(const basic_string<charT, ST, SA>& s, | 
|  | 617 | const basic_regex<charT, traits>& e, | 
|  | 618 | const basic_string<charT, FST, FSA>& fmt, | 
|  | 619 | regex_constants::match_flag_type flags = regex_constants::match_default); | 
|  | 620 |  | 
|  | 621 | template <class traits, class charT, class ST, class SA> | 
|  | 622 | basic_string<charT, ST, SA> | 
|  | 623 | regex_replace(const basic_string<charT, ST, SA>& s, | 
|  | 624 | const basic_regex<charT, traits>& e, const charT* fmt, | 
|  | 625 | regex_constants::match_flag_type flags = regex_constants::match_default); | 
|  | 626 |  | 
|  | 627 | template <class traits, class charT, class ST, class SA> | 
|  | 628 | basic_string<charT> | 
|  | 629 | regex_replace(const charT* s, | 
|  | 630 | const basic_regex<charT, traits>& e, | 
|  | 631 | const basic_string<charT, ST, SA>& fmt, | 
|  | 632 | regex_constants::match_flag_type flags = regex_constants::match_default); | 
|  | 633 |  | 
|  | 634 | template <class traits, class charT> | 
|  | 635 | basic_string<charT> | 
|  | 636 | regex_replace(const charT* s, | 
|  | 637 | const basic_regex<charT, traits>& e, | 
|  | 638 | const charT* fmt, | 
|  | 639 | regex_constants::match_flag_type flags = regex_constants::match_default); | 
|  | 640 |  | 
|  | 641 | template <class BidirectionalIterator, | 
|  | 642 | class charT = typename iterator_traits< BidirectionalIterator>::value_type, | 
|  | 643 | class traits = regex_traits<charT>> | 
|  | 644 | class regex_iterator | 
|  | 645 | { | 
|  | 646 | public: | 
|  | 647 | typedef basic_regex<charT, traits> regex_type; | 
|  | 648 | typedef match_results<BidirectionalIterator> value_type; | 
|  | 649 | typedef ptrdiff_t difference_type; | 
|  | 650 | typedef const value_type* pointer; | 
|  | 651 | typedef const value_type& reference; | 
|  | 652 | typedef forward_iterator_tag iterator_category; | 
|  | 653 |  | 
|  | 654 | regex_iterator(); | 
|  | 655 | regex_iterator(BidirectionalIterator a, BidirectionalIterator b, | 
|  | 656 | const regex_type& re, | 
|  | 657 | regex_constants::match_flag_type m = regex_constants::match_default); | 
|  | 658 | regex_iterator(const regex_iterator&); | 
|  | 659 | regex_iterator& operator=(const regex_iterator&); | 
|  | 660 |  | 
|  | 661 | bool operator==(const regex_iterator&) const; | 
|  | 662 | bool operator!=(const regex_iterator&) const; | 
|  | 663 |  | 
|  | 664 | const value_type& operator*() const; | 
|  | 665 | const value_type* operator->() const; | 
|  | 666 |  | 
|  | 667 | regex_iterator& operator++(); | 
|  | 668 | regex_iterator operator++(int); | 
|  | 669 | }; | 
|  | 670 |  | 
|  | 671 | typedef regex_iterator<const char*> cregex_iterator; | 
|  | 672 | typedef regex_iterator<const wchar_t*> wcregex_iterator; | 
|  | 673 | typedef regex_iterator<string::const_iterator> sregex_iterator; | 
|  | 674 | typedef regex_iterator<wstring::const_iterator> wsregex_iterator; | 
|  | 675 |  | 
|  | 676 | template <class BidirectionalIterator, | 
|  | 677 | class charT = typename iterator_traits< BidirectionalIterator>::value_type, | 
|  | 678 | class traits = regex_traits<charT>> | 
|  | 679 | class regex_token_iterator | 
|  | 680 | { | 
|  | 681 | public: | 
|  | 682 | typedef basic_regex<charT, traits> regex_type; | 
|  | 683 | typedef sub_match<BidirectionalIterator> value_type; | 
|  | 684 | typedef ptrdiff_t difference_type; | 
|  | 685 | typedef const value_type* pointer; | 
|  | 686 | typedef const value_type& reference; | 
|  | 687 | typedef forward_iterator_tag iterator_category; | 
|  | 688 |  | 
|  | 689 | regex_token_iterator(); | 
|  | 690 | regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b, | 
|  | 691 | const regex_type& re, int submatch = 0, | 
|  | 692 | regex_constants::match_flag_type m = regex_constants::match_default); | 
|  | 693 | regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b, | 
|  | 694 | const regex_type& re, const vector<int>& submatches, | 
|  | 695 | regex_constants::match_flag_type m = regex_constants::match_default); | 
|  | 696 | regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b, | 
|  | 697 | const regex_type& re, initializer_list<int> submatches, | 
|  | 698 | regex_constants::match_flag_type m = regex_constants::match_default); | 
|  | 699 | template <size_t N> | 
|  | 700 | regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b, | 
|  | 701 | const regex_type& re, const int (&submatches)[N], | 
|  | 702 | regex_constants::match_flag_type m = regex_constants::match_default); | 
|  | 703 | regex_token_iterator(const regex_token_iterator&); | 
|  | 704 | regex_token_iterator& operator=(const regex_token_iterator&); | 
|  | 705 |  | 
|  | 706 | bool operator==(const regex_token_iterator&) const; | 
|  | 707 | bool operator!=(const regex_token_iterator&) const; | 
|  | 708 |  | 
|  | 709 | const value_type& operator*() const; | 
|  | 710 | const value_type* operator->() const; | 
|  | 711 |  | 
|  | 712 | regex_token_iterator& operator++(); | 
|  | 713 | regex_token_iterator operator++(int); | 
|  | 714 | }; | 
|  | 715 |  | 
|  | 716 | typedef regex_token_iterator<const char*> cregex_token_iterator; | 
|  | 717 | typedef regex_token_iterator<const wchar_t*> wcregex_token_iterator; | 
|  | 718 | typedef regex_token_iterator<string::const_iterator> sregex_token_iterator; | 
|  | 719 | typedef regex_token_iterator<wstring::const_iterator> wsregex_token_iterator; | 
|  | 720 |  | 
|  | 721 | } // std | 
|  | 722 | */ | 
|  | 723 |  | 
|  | 724 | #include <__config> | 
|  | 725 | #include <stdexcept> | 
|  | 726 | #include <__locale> | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 727 | #include <initializer_list> | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 728 | #include <utility> | 
|  | 729 | #include <iterator> | 
|  | 730 | #include <string> | 
| Howard Hinnant | 7e9d84b | 2010-06-30 00:21:42 | [diff] [blame] | 731 | #include <memory> | 
|  | 732 | #include <vector> | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 733 | #include <deque> | 
| Howard Hinnant | 3257c98 | 2010-06-17 00:34:59 | [diff] [blame] | 734 |  | 
| Howard Hinnant | 66c6f97 | 2011-11-29 16:45:27 | [diff] [blame] | 735 | #include <__undef_min_max> | 
|  | 736 |  | 
| Howard Hinnant | 08e1747 | 2011-10-17 20:05:10 | [diff] [blame] | 737 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 
| Howard Hinnant | 3257c98 | 2010-06-17 00:34:59 | [diff] [blame] | 738 | #pragma GCC system_header | 
| Howard Hinnant | 08e1747 | 2011-10-17 20:05:10 | [diff] [blame] | 739 | #endif | 
| Howard Hinnant | 3257c98 | 2010-06-17 00:34:59 | [diff] [blame] | 740 |  | 
|  | 741 | _LIBCPP_BEGIN_NAMESPACE_STD | 
|  | 742 |  | 
|  | 743 | namespace regex_constants | 
|  | 744 | { | 
|  | 745 |  | 
|  | 746 | // syntax_option_type | 
|  | 747 |  | 
|  | 748 | enum syntax_option_type | 
|  | 749 | { | 
|  | 750 | icase = 1 << 0, | 
|  | 751 | nosubs = 1 << 1, | 
|  | 752 | optimize = 1 << 2, | 
|  | 753 | collate = 1 << 3, | 
| Howard Hinnant | ad2a7ab | 2010-07-27 17:24:17 | [diff] [blame] | 754 | ECMAScript = 0, | 
|  | 755 | basic = 1 << 4, | 
|  | 756 | extended = 1 << 5, | 
|  | 757 | awk = 1 << 6, | 
|  | 758 | grep = 1 << 7, | 
|  | 759 | egrep = 1 << 8 | 
| Howard Hinnant | 3257c98 | 2010-06-17 00:34:59 | [diff] [blame] | 760 | }; | 
|  | 761 |  | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 762 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 46623a0 | 2012-07-21 01:31:58 | [diff] [blame] | 763 | _LIBCPP_CONSTEXPR | 
| Howard Hinnant | 3257c98 | 2010-06-17 00:34:59 | [diff] [blame] | 764 | syntax_option_type | 
|  | 765 | operator~(syntax_option_type __x) | 
|  | 766 | { | 
|  | 767 | return syntax_option_type(~int(__x)); | 
|  | 768 | } | 
|  | 769 |  | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 770 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 46623a0 | 2012-07-21 01:31:58 | [diff] [blame] | 771 | _LIBCPP_CONSTEXPR | 
| Howard Hinnant | 3257c98 | 2010-06-17 00:34:59 | [diff] [blame] | 772 | syntax_option_type | 
|  | 773 | operator&(syntax_option_type __x, syntax_option_type __y) | 
|  | 774 | { | 
|  | 775 | return syntax_option_type(int(__x) & int(__y)); | 
|  | 776 | } | 
|  | 777 |  | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 778 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 46623a0 | 2012-07-21 01:31:58 | [diff] [blame] | 779 | _LIBCPP_CONSTEXPR | 
| Howard Hinnant | 3257c98 | 2010-06-17 00:34:59 | [diff] [blame] | 780 | syntax_option_type | 
|  | 781 | operator|(syntax_option_type __x, syntax_option_type __y) | 
|  | 782 | { | 
|  | 783 | return syntax_option_type(int(__x) | int(__y)); | 
|  | 784 | } | 
|  | 785 |  | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 786 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 46623a0 | 2012-07-21 01:31:58 | [diff] [blame] | 787 | _LIBCPP_CONSTEXPR | 
| Howard Hinnant | 3257c98 | 2010-06-17 00:34:59 | [diff] [blame] | 788 | syntax_option_type | 
|  | 789 | operator^(syntax_option_type __x, syntax_option_type __y) | 
|  | 790 | { | 
|  | 791 | return syntax_option_type(int(__x) ^ int(__y)); | 
|  | 792 | } | 
|  | 793 |  | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 794 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 3257c98 | 2010-06-17 00:34:59 | [diff] [blame] | 795 | syntax_option_type& | 
|  | 796 | operator&=(syntax_option_type& __x, syntax_option_type __y) | 
|  | 797 | { | 
|  | 798 | __x = __x & __y; | 
|  | 799 | return __x; | 
|  | 800 | } | 
|  | 801 |  | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 802 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 3257c98 | 2010-06-17 00:34:59 | [diff] [blame] | 803 | syntax_option_type& | 
|  | 804 | operator|=(syntax_option_type& __x, syntax_option_type __y) | 
|  | 805 | { | 
|  | 806 | __x = __x | __y; | 
|  | 807 | return __x; | 
|  | 808 | } | 
|  | 809 |  | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 810 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 3257c98 | 2010-06-17 00:34:59 | [diff] [blame] | 811 | syntax_option_type& | 
|  | 812 | operator^=(syntax_option_type& __x, syntax_option_type __y) | 
|  | 813 | { | 
|  | 814 | __x = __x ^ __y; | 
|  | 815 | return __x; | 
|  | 816 | } | 
|  | 817 |  | 
|  | 818 | // match_flag_type | 
|  | 819 |  | 
|  | 820 | enum match_flag_type | 
|  | 821 | { | 
|  | 822 | match_default = 0, | 
|  | 823 | match_not_bol = 1 << 0, | 
|  | 824 | match_not_eol = 1 << 1, | 
|  | 825 | match_not_bow = 1 << 2, | 
|  | 826 | match_not_eow = 1 << 3, | 
|  | 827 | match_any = 1 << 4, | 
|  | 828 | match_not_null = 1 << 5, | 
|  | 829 | match_continuous = 1 << 6, | 
|  | 830 | match_prev_avail = 1 << 7, | 
|  | 831 | format_default = 0, | 
|  | 832 | format_sed = 1 << 8, | 
|  | 833 | format_no_copy = 1 << 9, | 
| Howard Hinnant | a712c72 | 2010-08-16 20:21:16 | [diff] [blame] | 834 | format_first_only = 1 << 10, | 
|  | 835 | __no_update_pos = 1 << 11 | 
| Howard Hinnant | 3257c98 | 2010-06-17 00:34:59 | [diff] [blame] | 836 | }; | 
|  | 837 |  | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 838 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 46623a0 | 2012-07-21 01:31:58 | [diff] [blame] | 839 | _LIBCPP_CONSTEXPR | 
| Howard Hinnant | 3257c98 | 2010-06-17 00:34:59 | [diff] [blame] | 840 | match_flag_type | 
|  | 841 | operator~(match_flag_type __x) | 
|  | 842 | { | 
|  | 843 | return match_flag_type(~int(__x)); | 
|  | 844 | } | 
|  | 845 |  | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 846 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 46623a0 | 2012-07-21 01:31:58 | [diff] [blame] | 847 | _LIBCPP_CONSTEXPR | 
| Howard Hinnant | 3257c98 | 2010-06-17 00:34:59 | [diff] [blame] | 848 | match_flag_type | 
|  | 849 | operator&(match_flag_type __x, match_flag_type __y) | 
|  | 850 | { | 
|  | 851 | return match_flag_type(int(__x) & int(__y)); | 
|  | 852 | } | 
|  | 853 |  | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 854 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 46623a0 | 2012-07-21 01:31:58 | [diff] [blame] | 855 | _LIBCPP_CONSTEXPR | 
| Howard Hinnant | 3257c98 | 2010-06-17 00:34:59 | [diff] [blame] | 856 | match_flag_type | 
|  | 857 | operator|(match_flag_type __x, match_flag_type __y) | 
|  | 858 | { | 
|  | 859 | return match_flag_type(int(__x) | int(__y)); | 
|  | 860 | } | 
|  | 861 |  | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 862 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 46623a0 | 2012-07-21 01:31:58 | [diff] [blame] | 863 | _LIBCPP_CONSTEXPR | 
| Howard Hinnant | 3257c98 | 2010-06-17 00:34:59 | [diff] [blame] | 864 | match_flag_type | 
|  | 865 | operator^(match_flag_type __x, match_flag_type __y) | 
|  | 866 | { | 
|  | 867 | return match_flag_type(int(__x) ^ int(__y)); | 
|  | 868 | } | 
|  | 869 |  | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 870 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 3257c98 | 2010-06-17 00:34:59 | [diff] [blame] | 871 | match_flag_type& | 
|  | 872 | operator&=(match_flag_type& __x, match_flag_type __y) | 
|  | 873 | { | 
|  | 874 | __x = __x & __y; | 
|  | 875 | return __x; | 
|  | 876 | } | 
|  | 877 |  | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 878 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 3257c98 | 2010-06-17 00:34:59 | [diff] [blame] | 879 | match_flag_type& | 
|  | 880 | operator|=(match_flag_type& __x, match_flag_type __y) | 
|  | 881 | { | 
|  | 882 | __x = __x | __y; | 
|  | 883 | return __x; | 
|  | 884 | } | 
|  | 885 |  | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 886 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 3257c98 | 2010-06-17 00:34:59 | [diff] [blame] | 887 | match_flag_type& | 
|  | 888 | operator^=(match_flag_type& __x, match_flag_type __y) | 
|  | 889 | { | 
|  | 890 | __x = __x ^ __y; | 
|  | 891 | return __x; | 
|  | 892 | } | 
|  | 893 |  | 
|  | 894 | enum error_type | 
|  | 895 | { | 
|  | 896 | error_collate = 1, | 
|  | 897 | error_ctype, | 
|  | 898 | error_escape, | 
|  | 899 | error_backref, | 
|  | 900 | error_brack, | 
|  | 901 | error_paren, | 
|  | 902 | error_brace, | 
|  | 903 | error_badbrace, | 
|  | 904 | error_range, | 
|  | 905 | error_space, | 
|  | 906 | error_badrepeat, | 
|  | 907 | error_complexity, | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 908 | error_stack, | 
| Howard Hinnant | ad2a7ab | 2010-07-27 17:24:17 | [diff] [blame] | 909 | __re_err_grammar, | 
|  | 910 | __re_err_empty, | 
|  | 911 | __re_err_unknown | 
| Howard Hinnant | 3257c98 | 2010-06-17 00:34:59 | [diff] [blame] | 912 | }; | 
|  | 913 |  | 
|  | 914 | } // regex_constants | 
|  | 915 |  | 
|  | 916 | class _LIBCPP_EXCEPTION_ABI regex_error | 
|  | 917 | : public runtime_error | 
|  | 918 | { | 
|  | 919 | regex_constants::error_type __code_; | 
|  | 920 | public: | 
|  | 921 | explicit regex_error(regex_constants::error_type __ecode); | 
|  | 922 | virtual ~regex_error() throw(); | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 923 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 3257c98 | 2010-06-17 00:34:59 | [diff] [blame] | 924 | regex_constants::error_type code() const {return __code_;} | 
|  | 925 | }; | 
|  | 926 |  | 
|  | 927 | template <class _CharT> | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 928 | struct _LIBCPP_VISIBLE regex_traits | 
| Howard Hinnant | 3257c98 | 2010-06-17 00:34:59 | [diff] [blame] | 929 | { | 
|  | 930 | public: | 
|  | 931 | typedef _CharT char_type; | 
|  | 932 | typedef basic_string<char_type> string_type; | 
|  | 933 | typedef locale locale_type; | 
| Howard Hinnant | f409d2f | 2010-06-21 21:01:43 | [diff] [blame] | 934 | typedef ctype_base::mask char_class_type; | 
| Howard Hinnant | 3257c98 | 2010-06-17 00:34:59 | [diff] [blame] | 935 |  | 
| Howard Hinnant | f409d2f | 2010-06-21 21:01:43 | [diff] [blame] | 936 | static const char_class_type __regex_word = 0x80; | 
| Howard Hinnant | 3257c98 | 2010-06-17 00:34:59 | [diff] [blame] | 937 | private: | 
|  | 938 | locale __loc_; | 
|  | 939 | const ctype<char_type>* __ct_; | 
|  | 940 | const collate<char_type>* __col_; | 
|  | 941 |  | 
|  | 942 | public: | 
|  | 943 | regex_traits(); | 
|  | 944 |  | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 945 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 3257c98 | 2010-06-17 00:34:59 | [diff] [blame] | 946 | static size_t length(const char_type* __p) | 
|  | 947 | {return char_traits<char_type>::length(__p);} | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 948 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 3257c98 | 2010-06-17 00:34:59 | [diff] [blame] | 949 | char_type translate(char_type __c) const {return __c;} | 
|  | 950 | char_type translate_nocase(char_type __c) const; | 
|  | 951 | template <class _ForwardIterator> | 
|  | 952 | string_type | 
|  | 953 | transform(_ForwardIterator __f, _ForwardIterator __l) const; | 
|  | 954 | template <class _ForwardIterator> | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 955 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 3257c98 | 2010-06-17 00:34:59 | [diff] [blame] | 956 | string_type | 
|  | 957 | transform_primary( _ForwardIterator __f, _ForwardIterator __l) const | 
|  | 958 | {return __transform_primary(__f, __l, char_type());} | 
|  | 959 | template <class _ForwardIterator> | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 960 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 3257c98 | 2010-06-17 00:34:59 | [diff] [blame] | 961 | string_type | 
|  | 962 | lookup_collatename(_ForwardIterator __f, _ForwardIterator __l) const | 
|  | 963 | {return __lookup_collatename(__f, __l, char_type());} | 
|  | 964 | template <class _ForwardIterator> | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 965 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 3257c98 | 2010-06-17 00:34:59 | [diff] [blame] | 966 | char_class_type | 
|  | 967 | lookup_classname(_ForwardIterator __f, _ForwardIterator __l, | 
| Howard Hinnant | f409d2f | 2010-06-21 21:01:43 | [diff] [blame] | 968 | bool __icase = false) const | 
|  | 969 | {return __lookup_classname(__f, __l, __icase, char_type());} | 
|  | 970 | bool isctype(char_type __c, char_class_type __m) const; | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 971 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | f409d2f | 2010-06-21 21:01:43 | [diff] [blame] | 972 | int value(char_type __ch, int __radix) const | 
|  | 973 | {return __value(__ch, __radix);} | 
| Howard Hinnant | 3257c98 | 2010-06-17 00:34:59 | [diff] [blame] | 974 | locale_type imbue(locale_type __l); | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 975 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 3257c98 | 2010-06-17 00:34:59 | [diff] [blame] | 976 | locale_type getloc()const {return __loc_;} | 
|  | 977 |  | 
|  | 978 | private: | 
|  | 979 | void __init(); | 
|  | 980 |  | 
|  | 981 | template <class _ForwardIterator> | 
|  | 982 | string_type | 
|  | 983 | __transform_primary(_ForwardIterator __f, _ForwardIterator __l, char) const; | 
|  | 984 | template <class _ForwardIterator> | 
|  | 985 | string_type | 
|  | 986 | __transform_primary(_ForwardIterator __f, _ForwardIterator __l, wchar_t) const; | 
|  | 987 |  | 
|  | 988 | template <class _ForwardIterator> | 
|  | 989 | string_type | 
|  | 990 | __lookup_collatename(_ForwardIterator __f, _ForwardIterator __l, char) const; | 
|  | 991 | template <class _ForwardIterator> | 
|  | 992 | string_type | 
|  | 993 | __lookup_collatename(_ForwardIterator __f, _ForwardIterator __l, wchar_t) const; | 
| Howard Hinnant | f409d2f | 2010-06-21 21:01:43 | [diff] [blame] | 994 |  | 
|  | 995 | template <class _ForwardIterator> | 
|  | 996 | char_class_type | 
|  | 997 | __lookup_classname(_ForwardIterator __f, _ForwardIterator __l, | 
|  | 998 | bool __icase, char) const; | 
|  | 999 | template <class _ForwardIterator> | 
|  | 1000 | char_class_type | 
|  | 1001 | __lookup_classname(_ForwardIterator __f, _ForwardIterator __l, | 
|  | 1002 | bool __icase, wchar_t) const; | 
|  | 1003 |  | 
|  | 1004 | static int __value(unsigned char __ch, int __radix); | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 1005 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | f409d2f | 2010-06-21 21:01:43 | [diff] [blame] | 1006 | int __value(char __ch, int __radix) const | 
|  | 1007 | {return __value(static_cast<unsigned char>(__ch), __radix);} | 
|  | 1008 | int __value(wchar_t __ch, int __radix) const; | 
| Howard Hinnant | 3257c98 | 2010-06-17 00:34:59 | [diff] [blame] | 1009 | }; | 
|  | 1010 |  | 
|  | 1011 | template <class _CharT> | 
|  | 1012 | regex_traits<_CharT>::regex_traits() | 
|  | 1013 | { | 
|  | 1014 | __init(); | 
|  | 1015 | } | 
|  | 1016 |  | 
|  | 1017 | template <class _CharT> | 
|  | 1018 | typename regex_traits<_CharT>::char_type | 
|  | 1019 | regex_traits<_CharT>::translate_nocase(char_type __c) const | 
|  | 1020 | { | 
|  | 1021 | return __ct_->tolower(__c); | 
|  | 1022 | } | 
|  | 1023 |  | 
|  | 1024 | template <class _CharT> | 
|  | 1025 | template <class _ForwardIterator> | 
|  | 1026 | typename regex_traits<_CharT>::string_type | 
|  | 1027 | regex_traits<_CharT>::transform(_ForwardIterator __f, _ForwardIterator __l) const | 
|  | 1028 | { | 
|  | 1029 | string_type __s(__f, __l); | 
|  | 1030 | return __col_->transform(__s.data(), __s.data() + __s.size()); | 
|  | 1031 | } | 
|  | 1032 |  | 
|  | 1033 | template <class _CharT> | 
|  | 1034 | void | 
|  | 1035 | regex_traits<_CharT>::__init() | 
|  | 1036 | { | 
|  | 1037 | __ct_ = &use_facet<ctype<char_type> >(__loc_); | 
|  | 1038 | __col_ = &use_facet<collate<char_type> >(__loc_); | 
|  | 1039 | } | 
|  | 1040 |  | 
|  | 1041 | template <class _CharT> | 
|  | 1042 | typename regex_traits<_CharT>::locale_type | 
|  | 1043 | regex_traits<_CharT>::imbue(locale_type __l) | 
|  | 1044 | { | 
|  | 1045 | locale __r = __loc_; | 
|  | 1046 | __loc_ = __l; | 
|  | 1047 | __init(); | 
|  | 1048 | return __r; | 
|  | 1049 | } | 
|  | 1050 |  | 
|  | 1051 | // transform_primary is very FreeBSD-specific | 
|  | 1052 |  | 
|  | 1053 | template <class _CharT> | 
|  | 1054 | template <class _ForwardIterator> | 
|  | 1055 | typename regex_traits<_CharT>::string_type | 
|  | 1056 | regex_traits<_CharT>::__transform_primary(_ForwardIterator __f, | 
|  | 1057 | _ForwardIterator __l, char) const | 
|  | 1058 | { | 
|  | 1059 | const string_type __s(__f, __l); | 
|  | 1060 | string_type __d = __col_->transform(__s.data(), __s.data() + __s.size()); | 
|  | 1061 | switch (__d.size()) | 
|  | 1062 | { | 
|  | 1063 | case 1: | 
|  | 1064 | break; | 
|  | 1065 | case 12: | 
|  | 1066 | __d[11] = __d[3]; | 
|  | 1067 | break; | 
|  | 1068 | default: | 
|  | 1069 | __d.clear(); | 
|  | 1070 | break; | 
|  | 1071 | } | 
|  | 1072 | return __d; | 
|  | 1073 | } | 
|  | 1074 |  | 
|  | 1075 | template <class _CharT> | 
|  | 1076 | template <class _ForwardIterator> | 
|  | 1077 | typename regex_traits<_CharT>::string_type | 
|  | 1078 | regex_traits<_CharT>::__transform_primary(_ForwardIterator __f, | 
|  | 1079 | _ForwardIterator __l, wchar_t) const | 
|  | 1080 | { | 
|  | 1081 | const string_type __s(__f, __l); | 
|  | 1082 | string_type __d = __col_->transform(__s.data(), __s.data() + __s.size()); | 
|  | 1083 | switch (__d.size()) | 
|  | 1084 | { | 
|  | 1085 | case 1: | 
|  | 1086 | break; | 
|  | 1087 | case 3: | 
|  | 1088 | __d[2] = __d[0]; | 
|  | 1089 | break; | 
|  | 1090 | default: | 
|  | 1091 | __d.clear(); | 
|  | 1092 | break; | 
|  | 1093 | } | 
|  | 1094 | return __d; | 
|  | 1095 | } | 
|  | 1096 |  | 
|  | 1097 | // lookup_collatename is very FreeBSD-specific | 
|  | 1098 |  | 
| Howard Hinnant | f409d2f | 2010-06-21 21:01:43 | [diff] [blame] | 1099 | string __get_collation_name(const char* __s); | 
| Howard Hinnant | 3257c98 | 2010-06-17 00:34:59 | [diff] [blame] | 1100 |  | 
|  | 1101 | template <class _CharT> | 
|  | 1102 | template <class _ForwardIterator> | 
|  | 1103 | typename regex_traits<_CharT>::string_type | 
|  | 1104 | regex_traits<_CharT>::__lookup_collatename(_ForwardIterator __f, | 
|  | 1105 | _ForwardIterator __l, char) const | 
|  | 1106 | { | 
|  | 1107 | string_type __s(__f, __l); | 
|  | 1108 | string_type __r; | 
|  | 1109 | if (!__s.empty()) | 
|  | 1110 | { | 
|  | 1111 | __r = __get_collation_name(__s.c_str()); | 
|  | 1112 | if (__r.empty() && __s.size() <= 2) | 
|  | 1113 | { | 
|  | 1114 | __r = __col_->transform(__s.data(), __s.data() + __s.size()); | 
|  | 1115 | if (__r.size() == 1 || __r.size() == 12) | 
|  | 1116 | __r = __s; | 
|  | 1117 | else | 
|  | 1118 | __r.clear(); | 
|  | 1119 | } | 
|  | 1120 | } | 
|  | 1121 | return __r; | 
|  | 1122 | } | 
|  | 1123 |  | 
|  | 1124 | template <class _CharT> | 
|  | 1125 | template <class _ForwardIterator> | 
|  | 1126 | typename regex_traits<_CharT>::string_type | 
|  | 1127 | regex_traits<_CharT>::__lookup_collatename(_ForwardIterator __f, | 
|  | 1128 | _ForwardIterator __l, wchar_t) const | 
|  | 1129 | { | 
|  | 1130 | string_type __s(__f, __l); | 
|  | 1131 | string __n; | 
|  | 1132 | __n.reserve(__s.size()); | 
|  | 1133 | for (typename string_type::const_iterator __i = __s.begin(), __e = __s.end(); | 
|  | 1134 | __i != __e; ++__i) | 
|  | 1135 | { | 
|  | 1136 | if (static_cast<unsigned>(*__i) >= 127) | 
|  | 1137 | return string_type(); | 
|  | 1138 | __n.push_back(char(*__i)); | 
|  | 1139 | } | 
|  | 1140 | string_type __r; | 
|  | 1141 | if (!__s.empty()) | 
|  | 1142 | { | 
|  | 1143 | __n = __get_collation_name(__n.c_str()); | 
|  | 1144 | if (!__n.empty()) | 
|  | 1145 | __r.assign(__n.begin(), __n.end()); | 
|  | 1146 | else if (__s.size() <= 2) | 
|  | 1147 | { | 
|  | 1148 | __r = __col_->transform(__s.data(), __s.data() + __s.size()); | 
|  | 1149 | if (__r.size() == 1 || __r.size() == 3) | 
|  | 1150 | __r = __s; | 
|  | 1151 | else | 
|  | 1152 | __r.clear(); | 
|  | 1153 | } | 
|  | 1154 | } | 
|  | 1155 | return __r; | 
|  | 1156 | } | 
|  | 1157 |  | 
| Howard Hinnant | f409d2f | 2010-06-21 21:01:43 | [diff] [blame] | 1158 | // lookup_classname | 
|  | 1159 |  | 
|  | 1160 | ctype_base::mask __get_classname(const char* __s, bool __icase); | 
|  | 1161 |  | 
|  | 1162 | template <class _CharT> | 
|  | 1163 | template <class _ForwardIterator> | 
|  | 1164 | typename regex_traits<_CharT>::char_class_type | 
|  | 1165 | regex_traits<_CharT>::__lookup_classname(_ForwardIterator __f, | 
|  | 1166 | _ForwardIterator __l, | 
|  | 1167 | bool __icase, char) const | 
|  | 1168 | { | 
|  | 1169 | string_type __s(__f, __l); | 
|  | 1170 | __ct_->tolower(&__s[0], &__s[0] + __s.size()); | 
|  | 1171 | return __get_classname(__s.c_str(), __icase); | 
|  | 1172 | } | 
|  | 1173 |  | 
|  | 1174 | template <class _CharT> | 
|  | 1175 | template <class _ForwardIterator> | 
|  | 1176 | typename regex_traits<_CharT>::char_class_type | 
|  | 1177 | regex_traits<_CharT>::__lookup_classname(_ForwardIterator __f, | 
|  | 1178 | _ForwardIterator __l, | 
|  | 1179 | bool __icase, wchar_t) const | 
|  | 1180 | { | 
|  | 1181 | string_type __s(__f, __l); | 
|  | 1182 | __ct_->tolower(&__s[0], &__s[0] + __s.size()); | 
|  | 1183 | string __n; | 
|  | 1184 | __n.reserve(__s.size()); | 
|  | 1185 | for (typename string_type::const_iterator __i = __s.begin(), __e = __s.end(); | 
|  | 1186 | __i != __e; ++__i) | 
|  | 1187 | { | 
|  | 1188 | if (static_cast<unsigned>(*__i) >= 127) | 
|  | 1189 | return char_class_type(); | 
|  | 1190 | __n.push_back(char(*__i)); | 
|  | 1191 | } | 
|  | 1192 | return __get_classname(__n.c_str(), __icase); | 
|  | 1193 | } | 
|  | 1194 |  | 
|  | 1195 | template <class _CharT> | 
|  | 1196 | bool | 
|  | 1197 | regex_traits<_CharT>::isctype(char_type __c, char_class_type __m) const | 
|  | 1198 | { | 
|  | 1199 | if (__ct_->is(__m, __c)) | 
|  | 1200 | return true; | 
|  | 1201 | return (__c == '_' && (__m & __regex_word)); | 
|  | 1202 | } | 
|  | 1203 |  | 
|  | 1204 | template <class _CharT> | 
|  | 1205 | int | 
|  | 1206 | regex_traits<_CharT>::__value(unsigned char __ch, int __radix) | 
|  | 1207 | { | 
|  | 1208 | if ((__ch & 0xF8u) == 0x30) // '0' <= __ch && __ch <= '7' | 
|  | 1209 | return __ch - '0'; | 
|  | 1210 | if (__radix != 8) | 
|  | 1211 | { | 
|  | 1212 | if ((__ch & 0xFEu) == 0x38) // '8' <= __ch && __ch <= '9' | 
|  | 1213 | return __ch - '0'; | 
|  | 1214 | if (__radix == 16) | 
|  | 1215 | { | 
|  | 1216 | __ch |= 0x20; // tolower | 
|  | 1217 | if ('a' <= __ch && __ch <= 'f') | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 1218 | return __ch - ('a' - 10); | 
| Howard Hinnant | f409d2f | 2010-06-21 21:01:43 | [diff] [blame] | 1219 | } | 
|  | 1220 | } | 
|  | 1221 | return -1; | 
|  | 1222 | } | 
|  | 1223 |  | 
|  | 1224 | template <class _CharT> | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 1225 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | f409d2f | 2010-06-21 21:01:43 | [diff] [blame] | 1226 | int | 
|  | 1227 | regex_traits<_CharT>::__value(wchar_t __ch, int __radix) const | 
|  | 1228 | { | 
|  | 1229 | return __value(static_cast<unsigned char>(__ct_->narrow(__ch, char_type())), __radix); | 
|  | 1230 | } | 
|  | 1231 |  | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 1232 | template <class _CharT> class __node; | 
|  | 1233 |  | 
| Howard Hinnant | 33be35e | 2012-09-14 00:39:16 | [diff] [blame] | 1234 | template <class _BidirectionalIterator> class _LIBCPP_VISIBLE sub_match; | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 1235 |  | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 1236 | template <class _BidirectionalIterator, | 
|  | 1237 | class _Allocator = allocator<sub_match<_BidirectionalIterator> > > | 
| Howard Hinnant | 33be35e | 2012-09-14 00:39:16 | [diff] [blame] | 1238 | class _LIBCPP_VISIBLE match_results; | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 1239 |  | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 1240 | template <class _CharT> | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 1241 | struct __state | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 1242 | { | 
|  | 1243 | enum | 
|  | 1244 | { | 
|  | 1245 | __end_state = -1000, | 
|  | 1246 | __consume_input, // -999 | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 1247 | __begin_marked_expr, // -998 | 
|  | 1248 | __end_marked_expr, // -997 | 
| Howard Hinnant | e77aa5e | 2010-07-08 17:43:58 | [diff] [blame] | 1249 | __pop_state, // -996 | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 1250 | __accept_and_consume, // -995 | 
|  | 1251 | __accept_but_not_consume, // -994 | 
|  | 1252 | __reject, // -993 | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 1253 | __split, | 
|  | 1254 | __repeat | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 1255 | }; | 
|  | 1256 |  | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 1257 | int __do_; | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 1258 | const _CharT* __first_; | 
|  | 1259 | const _CharT* __current_; | 
|  | 1260 | const _CharT* __last_; | 
|  | 1261 | vector<sub_match<const _CharT*> > __sub_matches_; | 
|  | 1262 | vector<pair<size_t, const _CharT*> > __loop_data_; | 
|  | 1263 | const __node<_CharT>* __node_; | 
|  | 1264 | regex_constants::match_flag_type __flags_; | 
| Howard Hinnant | 41fb6e1 | 2011-03-26 20:02:27 | [diff] [blame] | 1265 | bool __at_first_; | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 1266 |  | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 1267 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 1268 | __state() | 
|  | 1269 | : __do_(0), __first_(nullptr), __current_(nullptr), __last_(nullptr), | 
|  | 1270 | __node_(nullptr), __flags_() {} | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 1271 | }; | 
|  | 1272 |  | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 1273 | // __node | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 1274 |  | 
|  | 1275 | template <class _CharT> | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 1276 | class __node | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 1277 | { | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 1278 | __node(const __node&); | 
|  | 1279 | __node& operator=(const __node&); | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 1280 | public: | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 1281 | typedef _VSTD::__state<_CharT> __state; | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 1282 |  | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 1283 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 1284 | __node() {} | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 1285 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 1286 | virtual ~__node() {} | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 1287 |  | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 1288 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 1289 | virtual void __exec(__state&) const {}; | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 1290 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 1291 | virtual void __exec_split(bool, __state&) const {}; | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 1292 | }; | 
|  | 1293 |  | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 1294 | // __end_state | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 1295 |  | 
|  | 1296 | template <class _CharT> | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 1297 | class __end_state | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 1298 | : public __node<_CharT> | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 1299 | { | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 1300 | public: | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 1301 | typedef _VSTD::__state<_CharT> __state; | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 1302 |  | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 1303 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 1304 | __end_state() {} | 
| Howard Hinnant | 9b80f2b | 2010-06-30 17:22:19 | [diff] [blame] | 1305 |  | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 1306 | virtual void __exec(__state&) const; | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 1307 | }; | 
|  | 1308 |  | 
|  | 1309 | template <class _CharT> | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 1310 | void | 
|  | 1311 | __end_state<_CharT>::__exec(__state& __s) const | 
| Howard Hinnant | 0dca5fc | 2010-06-30 20:30:19 | [diff] [blame] | 1312 | { | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 1313 | __s.__do_ = __state::__end_state; | 
| Howard Hinnant | 0dca5fc | 2010-06-30 20:30:19 | [diff] [blame] | 1314 | } | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 1315 |  | 
|  | 1316 | // __has_one_state | 
|  | 1317 |  | 
| Howard Hinnant | 0dca5fc | 2010-06-30 20:30:19 | [diff] [blame] | 1318 | template <class _CharT> | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 1319 | class __has_one_state | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 1320 | : public __node<_CharT> | 
| Howard Hinnant | 9b80f2b | 2010-06-30 17:22:19 | [diff] [blame] | 1321 | { | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 1322 | __node<_CharT>* __first_; | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 1323 |  | 
|  | 1324 | public: | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 1325 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 1326 | explicit __has_one_state(__node<_CharT>* __s) | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 1327 | : __first_(__s) {} | 
|  | 1328 |  | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 1329 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 1330 | __node<_CharT>* first() const {return __first_;} | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 1331 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 1332 | __node<_CharT>*& first() {return __first_;} | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 1333 | }; | 
|  | 1334 |  | 
|  | 1335 | // __owns_one_state | 
|  | 1336 |  | 
|  | 1337 | template <class _CharT> | 
|  | 1338 | class __owns_one_state | 
|  | 1339 | : public __has_one_state<_CharT> | 
|  | 1340 | { | 
|  | 1341 | typedef __has_one_state<_CharT> base; | 
|  | 1342 |  | 
|  | 1343 | public: | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 1344 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 1345 | explicit __owns_one_state(__node<_CharT>* __s) | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 1346 | : base(__s) {} | 
|  | 1347 |  | 
|  | 1348 | virtual ~__owns_one_state(); | 
|  | 1349 | }; | 
|  | 1350 |  | 
|  | 1351 | template <class _CharT> | 
|  | 1352 | __owns_one_state<_CharT>::~__owns_one_state() | 
|  | 1353 | { | 
|  | 1354 | delete this->first(); | 
| Howard Hinnant | 9b80f2b | 2010-06-30 17:22:19 | [diff] [blame] | 1355 | } | 
|  | 1356 |  | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 1357 | // __empty_state | 
|  | 1358 |  | 
|  | 1359 | template <class _CharT> | 
|  | 1360 | class __empty_state | 
|  | 1361 | : public __owns_one_state<_CharT> | 
|  | 1362 | { | 
|  | 1363 | typedef __owns_one_state<_CharT> base; | 
|  | 1364 |  | 
|  | 1365 | public: | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 1366 | typedef _VSTD::__state<_CharT> __state; | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 1367 |  | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 1368 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 1369 | explicit __empty_state(__node<_CharT>* __s) | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 1370 | : base(__s) {} | 
|  | 1371 |  | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 1372 | virtual void __exec(__state&) const; | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 1373 | }; | 
|  | 1374 |  | 
|  | 1375 | template <class _CharT> | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 1376 | void | 
|  | 1377 | __empty_state<_CharT>::__exec(__state& __s) const | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 1378 | { | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 1379 | __s.__do_ = __state::__accept_but_not_consume; | 
|  | 1380 | __s.__node_ = this->first(); | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 1381 | } | 
|  | 1382 |  | 
|  | 1383 | // __empty_non_own_state | 
|  | 1384 |  | 
|  | 1385 | template <class _CharT> | 
|  | 1386 | class __empty_non_own_state | 
|  | 1387 | : public __has_one_state<_CharT> | 
|  | 1388 | { | 
|  | 1389 | typedef __has_one_state<_CharT> base; | 
|  | 1390 |  | 
|  | 1391 | public: | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 1392 | typedef _VSTD::__state<_CharT> __state; | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 1393 |  | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 1394 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 1395 | explicit __empty_non_own_state(__node<_CharT>* __s) | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 1396 | : base(__s) {} | 
|  | 1397 |  | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 1398 | virtual void __exec(__state&) const; | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 1399 | }; | 
|  | 1400 |  | 
|  | 1401 | template <class _CharT> | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 1402 | void | 
|  | 1403 | __empty_non_own_state<_CharT>::__exec(__state& __s) const | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 1404 | { | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 1405 | __s.__do_ = __state::__accept_but_not_consume; | 
|  | 1406 | __s.__node_ = this->first(); | 
|  | 1407 | } | 
|  | 1408 |  | 
|  | 1409 | // __repeat_one_loop | 
|  | 1410 |  | 
|  | 1411 | template <class _CharT> | 
|  | 1412 | class __repeat_one_loop | 
|  | 1413 | : public __has_one_state<_CharT> | 
|  | 1414 | { | 
|  | 1415 | typedef __has_one_state<_CharT> base; | 
|  | 1416 |  | 
|  | 1417 | public: | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 1418 | typedef _VSTD::__state<_CharT> __state; | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 1419 |  | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 1420 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 1421 | explicit __repeat_one_loop(__node<_CharT>* __s) | 
|  | 1422 | : base(__s) {} | 
|  | 1423 |  | 
|  | 1424 | virtual void __exec(__state&) const; | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 1425 | }; | 
|  | 1426 |  | 
|  | 1427 | template <class _CharT> | 
|  | 1428 | void | 
|  | 1429 | __repeat_one_loop<_CharT>::__exec(__state& __s) const | 
|  | 1430 | { | 
|  | 1431 | __s.__do_ = __state::__repeat; | 
|  | 1432 | __s.__node_ = this->first(); | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 1433 | } | 
|  | 1434 |  | 
|  | 1435 | // __owns_two_states | 
|  | 1436 |  | 
|  | 1437 | template <class _CharT> | 
|  | 1438 | class __owns_two_states | 
|  | 1439 | : public __owns_one_state<_CharT> | 
|  | 1440 | { | 
|  | 1441 | typedef __owns_one_state<_CharT> base; | 
|  | 1442 |  | 
|  | 1443 | base* __second_; | 
|  | 1444 |  | 
|  | 1445 | public: | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 1446 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 1447 | explicit __owns_two_states(__node<_CharT>* __s1, base* __s2) | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 1448 | : base(__s1), __second_(__s2) {} | 
|  | 1449 |  | 
|  | 1450 | virtual ~__owns_two_states(); | 
|  | 1451 |  | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 1452 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 1453 | base* second() const {return __second_;} | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 1454 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 1455 | base*& second() {return __second_;} | 
|  | 1456 | }; | 
|  | 1457 |  | 
|  | 1458 | template <class _CharT> | 
|  | 1459 | __owns_two_states<_CharT>::~__owns_two_states() | 
|  | 1460 | { | 
|  | 1461 | delete __second_; | 
|  | 1462 | } | 
|  | 1463 |  | 
|  | 1464 | // __loop | 
|  | 1465 |  | 
|  | 1466 | template <class _CharT> | 
|  | 1467 | class __loop | 
|  | 1468 | : public __owns_two_states<_CharT> | 
|  | 1469 | { | 
|  | 1470 | typedef __owns_two_states<_CharT> base; | 
|  | 1471 |  | 
|  | 1472 | size_t __min_; | 
|  | 1473 | size_t __max_; | 
|  | 1474 | unsigned __loop_id_; | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 1475 | unsigned __mexp_begin_; | 
|  | 1476 | unsigned __mexp_end_; | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 1477 | bool __greedy_; | 
|  | 1478 |  | 
|  | 1479 | public: | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 1480 | typedef _VSTD::__state<_CharT> __state; | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 1481 |  | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 1482 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 1483 | explicit __loop(unsigned __loop_id, | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 1484 | __node<_CharT>* __s1, __owns_one_state<_CharT>* __s2, | 
|  | 1485 | unsigned __mexp_begin, unsigned __mexp_end, | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 1486 | bool __greedy = true, | 
|  | 1487 | size_t __min = 0, | 
|  | 1488 | size_t __max = numeric_limits<size_t>::max()) | 
|  | 1489 | : base(__s1, __s2), __min_(__min), __max_(__max), __loop_id_(__loop_id), | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 1490 | __mexp_begin_(__mexp_begin), __mexp_end_(__mexp_end), | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 1491 | __greedy_(__greedy) {} | 
|  | 1492 |  | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 1493 | virtual void __exec(__state& __s) const; | 
|  | 1494 | virtual void __exec_split(bool __second, __state& __s) const; | 
| Howard Hinnant | e77aa5e | 2010-07-08 17:43:58 | [diff] [blame] | 1495 |  | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 1496 | private: | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 1497 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 1498 | void __init_repeat(__state& __s) const | 
|  | 1499 | { | 
|  | 1500 | __s.__loop_data_[__loop_id_].second = __s.__current_; | 
|  | 1501 | for (size_t __i = __mexp_begin_-1; __i != __mexp_end_-1; ++__i) | 
|  | 1502 | { | 
|  | 1503 | __s.__sub_matches_[__i].first = __s.__last_; | 
|  | 1504 | __s.__sub_matches_[__i].second = __s.__last_; | 
|  | 1505 | __s.__sub_matches_[__i].matched = false; | 
|  | 1506 | } | 
|  | 1507 | } | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 1508 | }; | 
|  | 1509 |  | 
|  | 1510 | template <class _CharT> | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 1511 | void | 
|  | 1512 | __loop<_CharT>::__exec(__state& __s) const | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 1513 | { | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 1514 | if (__s.__do_ == __state::__repeat) | 
|  | 1515 | { | 
|  | 1516 | bool __do_repeat = ++__s.__loop_data_[__loop_id_].first < __max_; | 
|  | 1517 | bool __do_alt = __s.__loop_data_[__loop_id_].first >= __min_; | 
|  | 1518 | if (__do_repeat && __do_alt && | 
|  | 1519 | __s.__loop_data_[__loop_id_].second == __s.__current_) | 
|  | 1520 | __do_repeat = false; | 
|  | 1521 | if (__do_repeat && __do_alt) | 
|  | 1522 | __s.__do_ = __state::__split; | 
|  | 1523 | else if (__do_repeat) | 
|  | 1524 | { | 
|  | 1525 | __s.__do_ = __state::__accept_but_not_consume; | 
|  | 1526 | __s.__node_ = this->first(); | 
|  | 1527 | __init_repeat(__s); | 
|  | 1528 | } | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 1529 | else | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 1530 | { | 
|  | 1531 | __s.__do_ = __state::__accept_but_not_consume; | 
|  | 1532 | __s.__node_ = this->second(); | 
|  | 1533 | } | 
|  | 1534 | } | 
|  | 1535 | else | 
|  | 1536 | { | 
| Howard Hinnant | ad2a7ab | 2010-07-27 17:24:17 | [diff] [blame] | 1537 | __s.__loop_data_[__loop_id_].first = 0; | 
|  | 1538 | bool __do_repeat = 0 < __max_; | 
|  | 1539 | bool __do_alt = 0 >= __min_; | 
|  | 1540 | if (__do_repeat && __do_alt) | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 1541 | __s.__do_ = __state::__split; | 
| Howard Hinnant | ad2a7ab | 2010-07-27 17:24:17 | [diff] [blame] | 1542 | else if (__do_repeat) | 
|  | 1543 | { | 
|  | 1544 | __s.__do_ = __state::__accept_but_not_consume; | 
|  | 1545 | __s.__node_ = this->first(); | 
|  | 1546 | __init_repeat(__s); | 
|  | 1547 | } | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 1548 | else | 
|  | 1549 | { | 
|  | 1550 | __s.__do_ = __state::__accept_but_not_consume; | 
|  | 1551 | __s.__node_ = this->second(); | 
|  | 1552 | } | 
|  | 1553 | } | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 1554 | } | 
|  | 1555 |  | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 1556 | template <class _CharT> | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 1557 | void | 
|  | 1558 | __loop<_CharT>::__exec_split(bool __second, __state& __s) const | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 1559 | { | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 1560 | __s.__do_ = __state::__accept_but_not_consume; | 
|  | 1561 | if (__greedy_ != __second) | 
| Howard Hinnant | e77aa5e | 2010-07-08 17:43:58 | [diff] [blame] | 1562 | { | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 1563 | __s.__node_ = this->first(); | 
|  | 1564 | __init_repeat(__s); | 
| Howard Hinnant | e77aa5e | 2010-07-08 17:43:58 | [diff] [blame] | 1565 | } | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 1566 | else | 
|  | 1567 | __s.__node_ = this->second(); | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 1568 | } | 
|  | 1569 |  | 
| Howard Hinnant | aa69808 | 2010-07-16 19:08:36 | [diff] [blame] | 1570 | // __alternate | 
|  | 1571 |  | 
|  | 1572 | template <class _CharT> | 
|  | 1573 | class __alternate | 
|  | 1574 | : public __owns_two_states<_CharT> | 
|  | 1575 | { | 
|  | 1576 | typedef __owns_two_states<_CharT> base; | 
|  | 1577 |  | 
|  | 1578 | public: | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 1579 | typedef _VSTD::__state<_CharT> __state; | 
| Howard Hinnant | aa69808 | 2010-07-16 19:08:36 | [diff] [blame] | 1580 |  | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 1581 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | aa69808 | 2010-07-16 19:08:36 | [diff] [blame] | 1582 | explicit __alternate(__owns_one_state<_CharT>* __s1, | 
|  | 1583 | __owns_one_state<_CharT>* __s2) | 
|  | 1584 | : base(__s1, __s2) {} | 
|  | 1585 |  | 
|  | 1586 | virtual void __exec(__state& __s) const; | 
|  | 1587 | virtual void __exec_split(bool __second, __state& __s) const; | 
| Howard Hinnant | aa69808 | 2010-07-16 19:08:36 | [diff] [blame] | 1588 | }; | 
|  | 1589 |  | 
|  | 1590 | template <class _CharT> | 
|  | 1591 | void | 
|  | 1592 | __alternate<_CharT>::__exec(__state& __s) const | 
|  | 1593 | { | 
|  | 1594 | __s.__do_ = __state::__split; | 
|  | 1595 | } | 
|  | 1596 |  | 
|  | 1597 | template <class _CharT> | 
|  | 1598 | void | 
|  | 1599 | __alternate<_CharT>::__exec_split(bool __second, __state& __s) const | 
|  | 1600 | { | 
|  | 1601 | __s.__do_ = __state::__accept_but_not_consume; | 
| Howard Hinnant | 1371b2e | 2010-07-22 14:12:20 | [diff] [blame] | 1602 | if (__second) | 
| Howard Hinnant | aa69808 | 2010-07-16 19:08:36 | [diff] [blame] | 1603 | __s.__node_ = this->second(); | 
| Howard Hinnant | 1371b2e | 2010-07-22 14:12:20 | [diff] [blame] | 1604 | else | 
|  | 1605 | __s.__node_ = this->first(); | 
| Howard Hinnant | aa69808 | 2010-07-16 19:08:36 | [diff] [blame] | 1606 | } | 
|  | 1607 |  | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 1608 | // __begin_marked_subexpression | 
|  | 1609 |  | 
|  | 1610 | template <class _CharT> | 
|  | 1611 | class __begin_marked_subexpression | 
|  | 1612 | : public __owns_one_state<_CharT> | 
|  | 1613 | { | 
|  | 1614 | typedef __owns_one_state<_CharT> base; | 
|  | 1615 |  | 
| Howard Hinnant | e77aa5e | 2010-07-08 17:43:58 | [diff] [blame] | 1616 | unsigned __mexp_; | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 1617 | public: | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 1618 | typedef _VSTD::__state<_CharT> __state; | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 1619 |  | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 1620 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 1621 | explicit __begin_marked_subexpression(unsigned __mexp, __node<_CharT>* __s) | 
| Howard Hinnant | e77aa5e | 2010-07-08 17:43:58 | [diff] [blame] | 1622 | : base(__s), __mexp_(__mexp) {} | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 1623 |  | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 1624 | virtual void __exec(__state&) const; | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 1625 | }; | 
|  | 1626 |  | 
|  | 1627 | template <class _CharT> | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 1628 | void | 
|  | 1629 | __begin_marked_subexpression<_CharT>::__exec(__state& __s) const | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 1630 | { | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 1631 | __s.__do_ = __state::__accept_but_not_consume; | 
|  | 1632 | __s.__sub_matches_[__mexp_-1].first = __s.__current_; | 
|  | 1633 | __s.__node_ = this->first(); | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 1634 | } | 
|  | 1635 |  | 
|  | 1636 | // __end_marked_subexpression | 
|  | 1637 |  | 
|  | 1638 | template <class _CharT> | 
|  | 1639 | class __end_marked_subexpression | 
|  | 1640 | : public __owns_one_state<_CharT> | 
|  | 1641 | { | 
|  | 1642 | typedef __owns_one_state<_CharT> base; | 
|  | 1643 |  | 
| Howard Hinnant | e77aa5e | 2010-07-08 17:43:58 | [diff] [blame] | 1644 | unsigned __mexp_; | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 1645 | public: | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 1646 | typedef _VSTD::__state<_CharT> __state; | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 1647 |  | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 1648 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 1649 | explicit __end_marked_subexpression(unsigned __mexp, __node<_CharT>* __s) | 
| Howard Hinnant | e77aa5e | 2010-07-08 17:43:58 | [diff] [blame] | 1650 | : base(__s), __mexp_(__mexp) {} | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 1651 |  | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 1652 | virtual void __exec(__state&) const; | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 1653 | }; | 
|  | 1654 |  | 
|  | 1655 | template <class _CharT> | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 1656 | void | 
|  | 1657 | __end_marked_subexpression<_CharT>::__exec(__state& __s) const | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 1658 | { | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 1659 | __s.__do_ = __state::__accept_but_not_consume; | 
|  | 1660 | __s.__sub_matches_[__mexp_-1].second = __s.__current_; | 
|  | 1661 | __s.__sub_matches_[__mexp_-1].matched = true; | 
|  | 1662 | __s.__node_ = this->first(); | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 1663 | } | 
|  | 1664 |  | 
| Howard Hinnant | cba352d | 2010-07-12 18:16:05 | [diff] [blame] | 1665 | // __back_ref | 
|  | 1666 |  | 
|  | 1667 | template <class _CharT> | 
|  | 1668 | class __back_ref | 
|  | 1669 | : public __owns_one_state<_CharT> | 
|  | 1670 | { | 
|  | 1671 | typedef __owns_one_state<_CharT> base; | 
|  | 1672 |  | 
|  | 1673 | unsigned __mexp_; | 
|  | 1674 | public: | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 1675 | typedef _VSTD::__state<_CharT> __state; | 
| Howard Hinnant | cba352d | 2010-07-12 18:16:05 | [diff] [blame] | 1676 |  | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 1677 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | cba352d | 2010-07-12 18:16:05 | [diff] [blame] | 1678 | explicit __back_ref(unsigned __mexp, __node<_CharT>* __s) | 
|  | 1679 | : base(__s), __mexp_(__mexp) {} | 
|  | 1680 |  | 
|  | 1681 | virtual void __exec(__state&) const; | 
| Howard Hinnant | cba352d | 2010-07-12 18:16:05 | [diff] [blame] | 1682 | }; | 
|  | 1683 |  | 
|  | 1684 | template <class _CharT> | 
|  | 1685 | void | 
|  | 1686 | __back_ref<_CharT>::__exec(__state& __s) const | 
|  | 1687 | { | 
|  | 1688 | sub_match<const _CharT*>& __sm = __s.__sub_matches_[__mexp_-1]; | 
|  | 1689 | if (__sm.matched) | 
|  | 1690 | { | 
|  | 1691 | ptrdiff_t __len = __sm.second - __sm.first; | 
|  | 1692 | if (__s.__last_ - __s.__current_ >= __len && | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 1693 | _VSTD::equal(__sm.first, __sm.second, __s.__current_)) | 
| Howard Hinnant | cba352d | 2010-07-12 18:16:05 | [diff] [blame] | 1694 | { | 
|  | 1695 | __s.__do_ = __state::__accept_but_not_consume; | 
|  | 1696 | __s.__current_ += __len; | 
|  | 1697 | __s.__node_ = this->first(); | 
|  | 1698 | } | 
|  | 1699 | else | 
|  | 1700 | { | 
|  | 1701 | __s.__do_ = __state::__reject; | 
|  | 1702 | __s.__node_ = nullptr; | 
|  | 1703 | } | 
|  | 1704 | } | 
|  | 1705 | else | 
|  | 1706 | { | 
|  | 1707 | __s.__do_ = __state::__reject; | 
|  | 1708 | __s.__node_ = nullptr; | 
|  | 1709 | } | 
|  | 1710 | } | 
|  | 1711 |  | 
| Howard Hinnant | e34f17d | 2010-07-12 19:11:27 | [diff] [blame] | 1712 | // __back_ref_icase | 
|  | 1713 |  | 
|  | 1714 | template <class _CharT, class _Traits> | 
|  | 1715 | class __back_ref_icase | 
|  | 1716 | : public __owns_one_state<_CharT> | 
|  | 1717 | { | 
|  | 1718 | typedef __owns_one_state<_CharT> base; | 
|  | 1719 |  | 
|  | 1720 | _Traits __traits_; | 
|  | 1721 | unsigned __mexp_; | 
|  | 1722 | public: | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 1723 | typedef _VSTD::__state<_CharT> __state; | 
| Howard Hinnant | e34f17d | 2010-07-12 19:11:27 | [diff] [blame] | 1724 |  | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 1725 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | e34f17d | 2010-07-12 19:11:27 | [diff] [blame] | 1726 | explicit __back_ref_icase(const _Traits& __traits, unsigned __mexp, | 
|  | 1727 | __node<_CharT>* __s) | 
|  | 1728 | : base(__s), __traits_(__traits), __mexp_(__mexp) {} | 
|  | 1729 |  | 
|  | 1730 | virtual void __exec(__state&) const; | 
| Howard Hinnant | e34f17d | 2010-07-12 19:11:27 | [diff] [blame] | 1731 | }; | 
|  | 1732 |  | 
|  | 1733 | template <class _CharT, class _Traits> | 
|  | 1734 | void | 
|  | 1735 | __back_ref_icase<_CharT, _Traits>::__exec(__state& __s) const | 
|  | 1736 | { | 
|  | 1737 | sub_match<const _CharT*>& __sm = __s.__sub_matches_[__mexp_-1]; | 
|  | 1738 | if (__sm.matched) | 
|  | 1739 | { | 
|  | 1740 | ptrdiff_t __len = __sm.second - __sm.first; | 
|  | 1741 | if (__s.__last_ - __s.__current_ >= __len) | 
|  | 1742 | { | 
|  | 1743 | for (ptrdiff_t __i = 0; __i < __len; ++__i) | 
|  | 1744 | { | 
|  | 1745 | if (__traits_.translate_nocase(__sm.first[__i]) != | 
|  | 1746 | __traits_.translate_nocase(__s.__current_[__i])) | 
|  | 1747 | goto __not_equal; | 
|  | 1748 | } | 
|  | 1749 | __s.__do_ = __state::__accept_but_not_consume; | 
|  | 1750 | __s.__current_ += __len; | 
|  | 1751 | __s.__node_ = this->first(); | 
|  | 1752 | } | 
|  | 1753 | else | 
|  | 1754 | { | 
|  | 1755 | __s.__do_ = __state::__reject; | 
|  | 1756 | __s.__node_ = nullptr; | 
|  | 1757 | } | 
|  | 1758 | } | 
|  | 1759 | else | 
|  | 1760 | { | 
|  | 1761 | __not_equal: | 
|  | 1762 | __s.__do_ = __state::__reject; | 
|  | 1763 | __s.__node_ = nullptr; | 
|  | 1764 | } | 
|  | 1765 | } | 
|  | 1766 |  | 
|  | 1767 | // __back_ref_collate | 
|  | 1768 |  | 
|  | 1769 | template <class _CharT, class _Traits> | 
|  | 1770 | class __back_ref_collate | 
|  | 1771 | : public __owns_one_state<_CharT> | 
|  | 1772 | { | 
|  | 1773 | typedef __owns_one_state<_CharT> base; | 
|  | 1774 |  | 
|  | 1775 | _Traits __traits_; | 
|  | 1776 | unsigned __mexp_; | 
|  | 1777 | public: | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 1778 | typedef _VSTD::__state<_CharT> __state; | 
| Howard Hinnant | e34f17d | 2010-07-12 19:11:27 | [diff] [blame] | 1779 |  | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 1780 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | e34f17d | 2010-07-12 19:11:27 | [diff] [blame] | 1781 | explicit __back_ref_collate(const _Traits& __traits, unsigned __mexp, | 
|  | 1782 | __node<_CharT>* __s) | 
|  | 1783 | : base(__s), __traits_(__traits), __mexp_(__mexp) {} | 
|  | 1784 |  | 
|  | 1785 | virtual void __exec(__state&) const; | 
| Howard Hinnant | e34f17d | 2010-07-12 19:11:27 | [diff] [blame] | 1786 | }; | 
|  | 1787 |  | 
|  | 1788 | template <class _CharT, class _Traits> | 
|  | 1789 | void | 
|  | 1790 | __back_ref_collate<_CharT, _Traits>::__exec(__state& __s) const | 
|  | 1791 | { | 
|  | 1792 | sub_match<const _CharT*>& __sm = __s.__sub_matches_[__mexp_-1]; | 
|  | 1793 | if (__sm.matched) | 
|  | 1794 | { | 
|  | 1795 | ptrdiff_t __len = __sm.second - __sm.first; | 
|  | 1796 | if (__s.__last_ - __s.__current_ >= __len) | 
|  | 1797 | { | 
|  | 1798 | for (ptrdiff_t __i = 0; __i < __len; ++__i) | 
|  | 1799 | { | 
|  | 1800 | if (__traits_.translate(__sm.first[__i]) != | 
|  | 1801 | __traits_.translate(__s.__current_[__i])) | 
|  | 1802 | goto __not_equal; | 
|  | 1803 | } | 
|  | 1804 | __s.__do_ = __state::__accept_but_not_consume; | 
|  | 1805 | __s.__current_ += __len; | 
|  | 1806 | __s.__node_ = this->first(); | 
|  | 1807 | } | 
|  | 1808 | else | 
|  | 1809 | { | 
|  | 1810 | __s.__do_ = __state::__reject; | 
|  | 1811 | __s.__node_ = nullptr; | 
|  | 1812 | } | 
|  | 1813 | } | 
|  | 1814 | else | 
|  | 1815 | { | 
|  | 1816 | __not_equal: | 
|  | 1817 | __s.__do_ = __state::__reject; | 
|  | 1818 | __s.__node_ = nullptr; | 
|  | 1819 | } | 
|  | 1820 | } | 
|  | 1821 |  | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 1822 | // __word_boundary | 
|  | 1823 |  | 
|  | 1824 | template <class _CharT, class _Traits> | 
|  | 1825 | class __word_boundary | 
|  | 1826 | : public __owns_one_state<_CharT> | 
|  | 1827 | { | 
|  | 1828 | typedef __owns_one_state<_CharT> base; | 
|  | 1829 |  | 
|  | 1830 | _Traits __traits_; | 
|  | 1831 | bool __invert_; | 
|  | 1832 | public: | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 1833 | typedef _VSTD::__state<_CharT> __state; | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 1834 |  | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 1835 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 1836 | explicit __word_boundary(const _Traits& __traits, bool __invert, | 
|  | 1837 | __node<_CharT>* __s) | 
|  | 1838 | : base(__s), __traits_(__traits), __invert_(__invert) {} | 
|  | 1839 |  | 
|  | 1840 | virtual void __exec(__state&) const; | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 1841 | }; | 
|  | 1842 |  | 
|  | 1843 | template <class _CharT, class _Traits> | 
|  | 1844 | void | 
|  | 1845 | __word_boundary<_CharT, _Traits>::__exec(__state& __s) const | 
|  | 1846 | { | 
|  | 1847 | bool __is_word_b = false; | 
|  | 1848 | if (__s.__first_ != __s.__last_) | 
|  | 1849 | { | 
|  | 1850 | if (__s.__current_ == __s.__last_) | 
|  | 1851 | { | 
|  | 1852 | if (!(__s.__flags_ & regex_constants::match_not_eow)) | 
|  | 1853 | { | 
|  | 1854 | _CharT __c = __s.__current_[-1]; | 
|  | 1855 | __is_word_b = __c == '_' || | 
|  | 1856 | __traits_.isctype(__c, ctype_base::alnum); | 
|  | 1857 | } | 
|  | 1858 | } | 
| Howard Hinnant | f3dcca0 | 2010-07-29 15:17:28 | [diff] [blame] | 1859 | else if (__s.__current_ == __s.__first_ && | 
|  | 1860 | !(__s.__flags_ & regex_constants::match_prev_avail)) | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 1861 | { | 
|  | 1862 | if (!(__s.__flags_ & regex_constants::match_not_bow)) | 
|  | 1863 | { | 
|  | 1864 | _CharT __c = *__s.__current_; | 
|  | 1865 | __is_word_b = __c == '_' || | 
|  | 1866 | __traits_.isctype(__c, ctype_base::alnum); | 
|  | 1867 | } | 
|  | 1868 | } | 
|  | 1869 | else | 
|  | 1870 | { | 
|  | 1871 | _CharT __c1 = __s.__current_[-1]; | 
|  | 1872 | _CharT __c2 = *__s.__current_; | 
|  | 1873 | bool __is_c1_b = __c1 == '_' || | 
|  | 1874 | __traits_.isctype(__c1, ctype_base::alnum); | 
|  | 1875 | bool __is_c2_b = __c2 == '_' || | 
|  | 1876 | __traits_.isctype(__c2, ctype_base::alnum); | 
|  | 1877 | __is_word_b = __is_c1_b != __is_c2_b; | 
|  | 1878 | } | 
|  | 1879 | } | 
|  | 1880 | if (__is_word_b != __invert_) | 
|  | 1881 | { | 
|  | 1882 | __s.__do_ = __state::__accept_but_not_consume; | 
|  | 1883 | __s.__node_ = this->first(); | 
|  | 1884 | } | 
|  | 1885 | else | 
|  | 1886 | { | 
|  | 1887 | __s.__do_ = __state::__reject; | 
|  | 1888 | __s.__node_ = nullptr; | 
|  | 1889 | } | 
|  | 1890 | } | 
|  | 1891 |  | 
| Howard Hinnant | 41fb6e1 | 2011-03-26 20:02:27 | [diff] [blame] | 1892 | // __l_anchor | 
|  | 1893 |  | 
|  | 1894 | template <class _CharT> | 
|  | 1895 | class __l_anchor | 
|  | 1896 | : public __owns_one_state<_CharT> | 
|  | 1897 | { | 
|  | 1898 | typedef __owns_one_state<_CharT> base; | 
|  | 1899 |  | 
|  | 1900 | public: | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 1901 | typedef _VSTD::__state<_CharT> __state; | 
| Howard Hinnant | 41fb6e1 | 2011-03-26 20:02:27 | [diff] [blame] | 1902 |  | 
|  | 1903 | _LIBCPP_INLINE_VISIBILITY | 
|  | 1904 | __l_anchor(__node<_CharT>* __s) | 
|  | 1905 | : base(__s) {} | 
|  | 1906 |  | 
|  | 1907 | virtual void __exec(__state&) const; | 
|  | 1908 | }; | 
|  | 1909 |  | 
|  | 1910 | template <class _CharT> | 
|  | 1911 | void | 
|  | 1912 | __l_anchor<_CharT>::__exec(__state& __s) const | 
|  | 1913 | { | 
|  | 1914 | if (__s.__at_first_ && __s.__current_ == __s.__first_) | 
|  | 1915 | { | 
|  | 1916 | __s.__do_ = __state::__accept_but_not_consume; | 
|  | 1917 | __s.__node_ = this->first(); | 
|  | 1918 | } | 
|  | 1919 | else | 
|  | 1920 | { | 
|  | 1921 | __s.__do_ = __state::__reject; | 
|  | 1922 | __s.__node_ = nullptr; | 
|  | 1923 | } | 
|  | 1924 | } | 
|  | 1925 |  | 
| Howard Hinnant | 37f9f9c | 2010-07-09 00:15:26 | [diff] [blame] | 1926 | // __r_anchor | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 1927 |  | 
|  | 1928 | template <class _CharT> | 
| Howard Hinnant | 37f9f9c | 2010-07-09 00:15:26 | [diff] [blame] | 1929 | class __r_anchor | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 1930 | : public __owns_one_state<_CharT> | 
|  | 1931 | { | 
|  | 1932 | typedef __owns_one_state<_CharT> base; | 
|  | 1933 |  | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 1934 | public: | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 1935 | typedef _VSTD::__state<_CharT> __state; | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 1936 |  | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 1937 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 1938 | __r_anchor(__node<_CharT>* __s) | 
| Howard Hinnant | 37f9f9c | 2010-07-09 00:15:26 | [diff] [blame] | 1939 | : base(__s) {} | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 1940 |  | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 1941 | virtual void __exec(__state&) const; | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 1942 | }; | 
|  | 1943 |  | 
|  | 1944 | template <class _CharT> | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 1945 | void | 
|  | 1946 | __r_anchor<_CharT>::__exec(__state& __s) const | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 1947 | { | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 1948 | if (__s.__current_ == __s.__last_) | 
|  | 1949 | { | 
|  | 1950 | __s.__do_ = __state::__accept_but_not_consume; | 
|  | 1951 | __s.__node_ = this->first(); | 
|  | 1952 | } | 
|  | 1953 | else | 
|  | 1954 | { | 
|  | 1955 | __s.__do_ = __state::__reject; | 
|  | 1956 | __s.__node_ = nullptr; | 
|  | 1957 | } | 
|  | 1958 | } | 
|  | 1959 |  | 
|  | 1960 | // __match_any | 
|  | 1961 |  | 
|  | 1962 | template <class _CharT> | 
|  | 1963 | class __match_any | 
|  | 1964 | : public __owns_one_state<_CharT> | 
|  | 1965 | { | 
|  | 1966 | typedef __owns_one_state<_CharT> base; | 
|  | 1967 |  | 
|  | 1968 | public: | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 1969 | typedef _VSTD::__state<_CharT> __state; | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 1970 |  | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 1971 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 1972 | __match_any(__node<_CharT>* __s) | 
|  | 1973 | : base(__s) {} | 
|  | 1974 |  | 
|  | 1975 | virtual void __exec(__state&) const; | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 1976 | }; | 
|  | 1977 |  | 
|  | 1978 | template <class _CharT> | 
|  | 1979 | void | 
|  | 1980 | __match_any<_CharT>::__exec(__state& __s) const | 
|  | 1981 | { | 
|  | 1982 | if (__s.__current_ != __s.__last_ && *__s.__current_ != 0) | 
|  | 1983 | { | 
|  | 1984 | __s.__do_ = __state::__accept_and_consume; | 
|  | 1985 | ++__s.__current_; | 
|  | 1986 | __s.__node_ = this->first(); | 
|  | 1987 | } | 
|  | 1988 | else | 
|  | 1989 | { | 
|  | 1990 | __s.__do_ = __state::__reject; | 
|  | 1991 | __s.__node_ = nullptr; | 
|  | 1992 | } | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 1993 | } | 
|  | 1994 |  | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 1995 | // __match_any_but_newline | 
|  | 1996 |  | 
|  | 1997 | template <class _CharT> | 
|  | 1998 | class __match_any_but_newline | 
|  | 1999 | : public __owns_one_state<_CharT> | 
|  | 2000 | { | 
|  | 2001 | typedef __owns_one_state<_CharT> base; | 
|  | 2002 |  | 
|  | 2003 | public: | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 2004 | typedef _VSTD::__state<_CharT> __state; | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 2005 |  | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 2006 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 2007 | __match_any_but_newline(__node<_CharT>* __s) | 
|  | 2008 | : base(__s) {} | 
|  | 2009 |  | 
|  | 2010 | virtual void __exec(__state&) const; | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 2011 | }; | 
|  | 2012 |  | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 2013 | // __match_char | 
|  | 2014 |  | 
| Howard Hinnant | 9b80f2b | 2010-06-30 17:22:19 | [diff] [blame] | 2015 | template <class _CharT> | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 2016 | class __match_char | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 2017 | : public __owns_one_state<_CharT> | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 2018 | { | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 2019 | typedef __owns_one_state<_CharT> base; | 
|  | 2020 |  | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 2021 | _CharT __c_; | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 2022 |  | 
|  | 2023 | __match_char(const __match_char&); | 
|  | 2024 | __match_char& operator=(const __match_char&); | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 2025 | public: | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 2026 | typedef _VSTD::__state<_CharT> __state; | 
| Howard Hinnant | 0dca5fc | 2010-06-30 20:30:19 | [diff] [blame] | 2027 |  | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 2028 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 2029 | __match_char(_CharT __c, __node<_CharT>* __s) | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 2030 | : base(__s), __c_(__c) {} | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 2031 |  | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 2032 | virtual void __exec(__state&) const; | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 2033 | }; | 
|  | 2034 |  | 
| Howard Hinnant | 0dca5fc | 2010-06-30 20:30:19 | [diff] [blame] | 2035 | template <class _CharT> | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 2036 | void | 
|  | 2037 | __match_char<_CharT>::__exec(__state& __s) const | 
| Howard Hinnant | 0dca5fc | 2010-06-30 20:30:19 | [diff] [blame] | 2038 | { | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 2039 | if (__s.__current_ != __s.__last_ && *__s.__current_ == __c_) | 
|  | 2040 | { | 
|  | 2041 | __s.__do_ = __state::__accept_and_consume; | 
|  | 2042 | ++__s.__current_; | 
|  | 2043 | __s.__node_ = this->first(); | 
|  | 2044 | } | 
|  | 2045 | else | 
|  | 2046 | { | 
|  | 2047 | __s.__do_ = __state::__reject; | 
|  | 2048 | __s.__node_ = nullptr; | 
|  | 2049 | } | 
| Howard Hinnant | 0dca5fc | 2010-06-30 20:30:19 | [diff] [blame] | 2050 | } | 
| Howard Hinnant | 0dca5fc | 2010-06-30 20:30:19 | [diff] [blame] | 2051 |  | 
| Howard Hinnant | e34f17d | 2010-07-12 19:11:27 | [diff] [blame] | 2052 | // __match_char_icase | 
|  | 2053 |  | 
|  | 2054 | template <class _CharT, class _Traits> | 
|  | 2055 | class __match_char_icase | 
|  | 2056 | : public __owns_one_state<_CharT> | 
|  | 2057 | { | 
|  | 2058 | typedef __owns_one_state<_CharT> base; | 
|  | 2059 |  | 
|  | 2060 | _Traits __traits_; | 
|  | 2061 | _CharT __c_; | 
|  | 2062 |  | 
|  | 2063 | __match_char_icase(const __match_char_icase&); | 
|  | 2064 | __match_char_icase& operator=(const __match_char_icase&); | 
|  | 2065 | public: | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 2066 | typedef _VSTD::__state<_CharT> __state; | 
| Howard Hinnant | e34f17d | 2010-07-12 19:11:27 | [diff] [blame] | 2067 |  | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 2068 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | e34f17d | 2010-07-12 19:11:27 | [diff] [blame] | 2069 | __match_char_icase(const _Traits& __traits, _CharT __c, __node<_CharT>* __s) | 
|  | 2070 | : base(__s), __traits_(__traits), __c_(__traits.translate_nocase(__c)) {} | 
|  | 2071 |  | 
|  | 2072 | virtual void __exec(__state&) const; | 
| Howard Hinnant | e34f17d | 2010-07-12 19:11:27 | [diff] [blame] | 2073 | }; | 
|  | 2074 |  | 
|  | 2075 | template <class _CharT, class _Traits> | 
|  | 2076 | void | 
|  | 2077 | __match_char_icase<_CharT, _Traits>::__exec(__state& __s) const | 
|  | 2078 | { | 
|  | 2079 | if (__s.__current_ != __s.__last_ && | 
|  | 2080 | __traits_.translate_nocase(*__s.__current_) == __c_) | 
|  | 2081 | { | 
|  | 2082 | __s.__do_ = __state::__accept_and_consume; | 
|  | 2083 | ++__s.__current_; | 
|  | 2084 | __s.__node_ = this->first(); | 
|  | 2085 | } | 
|  | 2086 | else | 
|  | 2087 | { | 
|  | 2088 | __s.__do_ = __state::__reject; | 
|  | 2089 | __s.__node_ = nullptr; | 
|  | 2090 | } | 
|  | 2091 | } | 
|  | 2092 |  | 
|  | 2093 | // __match_char_collate | 
|  | 2094 |  | 
|  | 2095 | template <class _CharT, class _Traits> | 
|  | 2096 | class __match_char_collate | 
|  | 2097 | : public __owns_one_state<_CharT> | 
|  | 2098 | { | 
|  | 2099 | typedef __owns_one_state<_CharT> base; | 
|  | 2100 |  | 
|  | 2101 | _Traits __traits_; | 
|  | 2102 | _CharT __c_; | 
|  | 2103 |  | 
|  | 2104 | __match_char_collate(const __match_char_collate&); | 
|  | 2105 | __match_char_collate& operator=(const __match_char_collate&); | 
|  | 2106 | public: | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 2107 | typedef _VSTD::__state<_CharT> __state; | 
| Howard Hinnant | e34f17d | 2010-07-12 19:11:27 | [diff] [blame] | 2108 |  | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 2109 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | e34f17d | 2010-07-12 19:11:27 | [diff] [blame] | 2110 | __match_char_collate(const _Traits& __traits, _CharT __c, __node<_CharT>* __s) | 
|  | 2111 | : base(__s), __traits_(__traits), __c_(__traits.translate(__c)) {} | 
|  | 2112 |  | 
|  | 2113 | virtual void __exec(__state&) const; | 
| Howard Hinnant | e34f17d | 2010-07-12 19:11:27 | [diff] [blame] | 2114 | }; | 
|  | 2115 |  | 
|  | 2116 | template <class _CharT, class _Traits> | 
|  | 2117 | void | 
|  | 2118 | __match_char_collate<_CharT, _Traits>::__exec(__state& __s) const | 
|  | 2119 | { | 
|  | 2120 | if (__s.__current_ != __s.__last_ && | 
|  | 2121 | __traits_.translate(*__s.__current_) == __c_) | 
|  | 2122 | { | 
|  | 2123 | __s.__do_ = __state::__accept_and_consume; | 
|  | 2124 | ++__s.__current_; | 
|  | 2125 | __s.__node_ = this->first(); | 
|  | 2126 | } | 
|  | 2127 | else | 
|  | 2128 | { | 
|  | 2129 | __s.__do_ = __state::__reject; | 
|  | 2130 | __s.__node_ = nullptr; | 
|  | 2131 | } | 
|  | 2132 | } | 
|  | 2133 |  | 
| Howard Hinnant | 173968a | 2010-07-13 21:48:06 | [diff] [blame] | 2134 | // __bracket_expression | 
|  | 2135 |  | 
|  | 2136 | template <class _CharT, class _Traits> | 
|  | 2137 | class __bracket_expression | 
|  | 2138 | : public __owns_one_state<_CharT> | 
|  | 2139 | { | 
|  | 2140 | typedef __owns_one_state<_CharT> base; | 
|  | 2141 | typedef typename _Traits::string_type string_type; | 
|  | 2142 |  | 
|  | 2143 | _Traits __traits_; | 
|  | 2144 | vector<_CharT> __chars_; | 
| Howard Hinnant | 15476f3 | 2010-07-28 17:35:27 | [diff] [blame] | 2145 | vector<_CharT> __neg_chars_; | 
| Howard Hinnant | 173968a | 2010-07-13 21:48:06 | [diff] [blame] | 2146 | vector<pair<string_type, string_type> > __ranges_; | 
|  | 2147 | vector<pair<_CharT, _CharT> > __digraphs_; | 
|  | 2148 | vector<string_type> __equivalences_; | 
|  | 2149 | ctype_base::mask __mask_; | 
| Howard Hinnant | 15476f3 | 2010-07-28 17:35:27 | [diff] [blame] | 2150 | ctype_base::mask __neg_mask_; | 
| Howard Hinnant | 173968a | 2010-07-13 21:48:06 | [diff] [blame] | 2151 | bool __negate_; | 
|  | 2152 | bool __icase_; | 
|  | 2153 | bool __collate_; | 
| Howard Hinnant | 68025ed | 2010-07-14 15:45:11 | [diff] [blame] | 2154 | bool __might_have_digraph_; | 
| Howard Hinnant | 173968a | 2010-07-13 21:48:06 | [diff] [blame] | 2155 |  | 
|  | 2156 | __bracket_expression(const __bracket_expression&); | 
|  | 2157 | __bracket_expression& operator=(const __bracket_expression&); | 
|  | 2158 | public: | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 2159 | typedef _VSTD::__state<_CharT> __state; | 
| Howard Hinnant | 173968a | 2010-07-13 21:48:06 | [diff] [blame] | 2160 |  | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 2161 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 173968a | 2010-07-13 21:48:06 | [diff] [blame] | 2162 | __bracket_expression(const _Traits& __traits, __node<_CharT>* __s, | 
|  | 2163 | bool __negate, bool __icase, bool __collate) | 
| Howard Hinnant | 15476f3 | 2010-07-28 17:35:27 | [diff] [blame] | 2164 | : base(__s), __traits_(__traits), __mask_(), __neg_mask_(), | 
|  | 2165 | __negate_(__negate), __icase_(__icase), __collate_(__collate), | 
| Howard Hinnant | 68025ed | 2010-07-14 15:45:11 | [diff] [blame] | 2166 | __might_have_digraph_(__traits_.getloc().name() != "C") {} | 
| Howard Hinnant | 173968a | 2010-07-13 21:48:06 | [diff] [blame] | 2167 |  | 
|  | 2168 | virtual void __exec(__state&) const; | 
|  | 2169 |  | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 2170 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 15476f3 | 2010-07-28 17:35:27 | [diff] [blame] | 2171 | bool __negated() const {return __negate_;} | 
|  | 2172 |  | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 2173 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 173968a | 2010-07-13 21:48:06 | [diff] [blame] | 2174 | void __add_char(_CharT __c) | 
|  | 2175 | { | 
|  | 2176 | if (__icase_) | 
|  | 2177 | __chars_.push_back(__traits_.translate_nocase(__c)); | 
|  | 2178 | else if (__collate_) | 
|  | 2179 | __chars_.push_back(__traits_.translate(__c)); | 
|  | 2180 | else | 
|  | 2181 | __chars_.push_back(__c); | 
|  | 2182 | } | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 2183 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 15476f3 | 2010-07-28 17:35:27 | [diff] [blame] | 2184 | void __add_neg_char(_CharT __c) | 
|  | 2185 | { | 
|  | 2186 | if (__icase_) | 
|  | 2187 | __neg_chars_.push_back(__traits_.translate_nocase(__c)); | 
|  | 2188 | else if (__collate_) | 
|  | 2189 | __neg_chars_.push_back(__traits_.translate(__c)); | 
|  | 2190 | else | 
|  | 2191 | __neg_chars_.push_back(__c); | 
|  | 2192 | } | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 2193 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 173968a | 2010-07-13 21:48:06 | [diff] [blame] | 2194 | void __add_range(string_type __b, string_type __e) | 
|  | 2195 | { | 
|  | 2196 | if (__collate_) | 
|  | 2197 | { | 
|  | 2198 | if (__icase_) | 
|  | 2199 | { | 
|  | 2200 | for (size_t __i = 0; __i < __b.size(); ++__i) | 
|  | 2201 | __b[__i] = __traits_.translate_nocase(__b[__i]); | 
|  | 2202 | for (size_t __i = 0; __i < __e.size(); ++__i) | 
|  | 2203 | __e[__i] = __traits_.translate_nocase(__e[__i]); | 
|  | 2204 | } | 
|  | 2205 | else | 
|  | 2206 | { | 
|  | 2207 | for (size_t __i = 0; __i < __b.size(); ++__i) | 
|  | 2208 | __b[__i] = __traits_.translate(__b[__i]); | 
|  | 2209 | for (size_t __i = 0; __i < __e.size(); ++__i) | 
|  | 2210 | __e[__i] = __traits_.translate(__e[__i]); | 
|  | 2211 | } | 
|  | 2212 | __ranges_.push_back(make_pair( | 
|  | 2213 | __traits_.transform(__b.begin(), __b.end()), | 
|  | 2214 | __traits_.transform(__e.begin(), __e.end()))); | 
|  | 2215 | } | 
|  | 2216 | else | 
|  | 2217 | { | 
| Howard Hinnant | d444470 | 2010-08-11 17:04:31 | [diff] [blame] | 2218 | #ifndef _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | 173968a | 2010-07-13 21:48:06 | [diff] [blame] | 2219 | if (__b.size() != 1 || __e.size() != 1) | 
|  | 2220 | throw regex_error(regex_constants::error_collate); | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 | [diff] [blame] | 2221 | #endif // _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | 173968a | 2010-07-13 21:48:06 | [diff] [blame] | 2222 | if (__icase_) | 
|  | 2223 | { | 
|  | 2224 | __b[0] = __traits_.translate_nocase(__b[0]); | 
|  | 2225 | __e[0] = __traits_.translate_nocase(__e[0]); | 
|  | 2226 | } | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 2227 | __ranges_.push_back(make_pair(_VSTD::move(__b), _VSTD::move(__e))); | 
| Howard Hinnant | 173968a | 2010-07-13 21:48:06 | [diff] [blame] | 2228 | } | 
|  | 2229 | } | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 2230 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 173968a | 2010-07-13 21:48:06 | [diff] [blame] | 2231 | void __add_digraph(_CharT __c1, _CharT __c2) | 
|  | 2232 | { | 
|  | 2233 | if (__icase_) | 
|  | 2234 | __digraphs_.push_back(make_pair(__traits_.translate_nocase(__c1), | 
|  | 2235 | __traits_.translate_nocase(__c2))); | 
|  | 2236 | else if (__collate_) | 
|  | 2237 | __digraphs_.push_back(make_pair(__traits_.translate(__c1), | 
|  | 2238 | __traits_.translate(__c2))); | 
|  | 2239 | else | 
|  | 2240 | __digraphs_.push_back(make_pair(__c1, __c2)); | 
|  | 2241 | } | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 2242 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 173968a | 2010-07-13 21:48:06 | [diff] [blame] | 2243 | void __add_equivalence(const string_type& __s) | 
|  | 2244 | {__equivalences_.push_back(__s);} | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 2245 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 173968a | 2010-07-13 21:48:06 | [diff] [blame] | 2246 | void __add_class(ctype_base::mask __mask) | 
|  | 2247 | {__mask_ |= __mask;} | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 2248 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 15476f3 | 2010-07-28 17:35:27 | [diff] [blame] | 2249 | void __add_neg_class(ctype_base::mask __mask) | 
|  | 2250 | {__neg_mask_ |= __mask;} | 
| Howard Hinnant | 173968a | 2010-07-13 21:48:06 | [diff] [blame] | 2251 | }; | 
|  | 2252 |  | 
|  | 2253 | template <class _CharT, class _Traits> | 
|  | 2254 | void | 
|  | 2255 | __bracket_expression<_CharT, _Traits>::__exec(__state& __s) const | 
|  | 2256 | { | 
|  | 2257 | bool __found = false; | 
|  | 2258 | unsigned __consumed = 0; | 
|  | 2259 | if (__s.__current_ != __s.__last_) | 
|  | 2260 | { | 
|  | 2261 | ++__consumed; | 
| Howard Hinnant | 68025ed | 2010-07-14 15:45:11 | [diff] [blame] | 2262 | if (__might_have_digraph_) | 
| Howard Hinnant | 173968a | 2010-07-13 21:48:06 | [diff] [blame] | 2263 | { | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 2264 | const _CharT* __next = _VSTD::next(__s.__current_); | 
| Howard Hinnant | 68025ed | 2010-07-14 15:45:11 | [diff] [blame] | 2265 | if (__next != __s.__last_) | 
| Howard Hinnant | 173968a | 2010-07-13 21:48:06 | [diff] [blame] | 2266 | { | 
| Howard Hinnant | 68025ed | 2010-07-14 15:45:11 | [diff] [blame] | 2267 | pair<_CharT, _CharT> __ch2(*__s.__current_, *__next); | 
|  | 2268 | if (__icase_) | 
| Howard Hinnant | 173968a | 2010-07-13 21:48:06 | [diff] [blame] | 2269 | { | 
| Howard Hinnant | 68025ed | 2010-07-14 15:45:11 | [diff] [blame] | 2270 | __ch2.first = __traits_.translate_nocase(__ch2.first); | 
|  | 2271 | __ch2.second = __traits_.translate_nocase(__ch2.second); | 
|  | 2272 | } | 
|  | 2273 | else if (__collate_) | 
|  | 2274 | { | 
|  | 2275 | __ch2.first = __traits_.translate(__ch2.first); | 
|  | 2276 | __ch2.second = __traits_.translate(__ch2.second); | 
|  | 2277 | } | 
|  | 2278 | if (!__traits_.lookup_collatename(&__ch2.first, &__ch2.first+2).empty()) | 
|  | 2279 | { | 
|  | 2280 | // __ch2 is a digraph in this locale | 
|  | 2281 | ++__consumed; | 
|  | 2282 | for (size_t __i = 0; __i < __digraphs_.size(); ++__i) | 
|  | 2283 | { | 
|  | 2284 | if (__ch2 == __digraphs_[__i]) | 
|  | 2285 | { | 
|  | 2286 | __found = true; | 
|  | 2287 | goto __exit; | 
|  | 2288 | } | 
|  | 2289 | } | 
|  | 2290 | if (__collate_ && !__ranges_.empty()) | 
|  | 2291 | { | 
|  | 2292 | string_type __s2 = __traits_.transform(&__ch2.first, | 
|  | 2293 | &__ch2.first + 2); | 
|  | 2294 | for (size_t __i = 0; __i < __ranges_.size(); ++__i) | 
|  | 2295 | { | 
|  | 2296 | if (__ranges_[__i].first <= __s2 && | 
|  | 2297 | __s2 <= __ranges_[__i].second) | 
|  | 2298 | { | 
|  | 2299 | __found = true; | 
|  | 2300 | goto __exit; | 
|  | 2301 | } | 
|  | 2302 | } | 
|  | 2303 | } | 
|  | 2304 | if (!__equivalences_.empty()) | 
|  | 2305 | { | 
|  | 2306 | string_type __s2 = __traits_.transform_primary(&__ch2.first, | 
|  | 2307 | &__ch2.first + 2); | 
|  | 2308 | for (size_t __i = 0; __i < __equivalences_.size(); ++__i) | 
|  | 2309 | { | 
|  | 2310 | if (__s2 == __equivalences_[__i]) | 
|  | 2311 | { | 
|  | 2312 | __found = true; | 
|  | 2313 | goto __exit; | 
|  | 2314 | } | 
|  | 2315 | } | 
|  | 2316 | } | 
|  | 2317 | if (__traits_.isctype(__ch2.first, __mask_) && | 
|  | 2318 | __traits_.isctype(__ch2.second, __mask_)) | 
| Howard Hinnant | 173968a | 2010-07-13 21:48:06 | [diff] [blame] | 2319 | { | 
|  | 2320 | __found = true; | 
|  | 2321 | goto __exit; | 
|  | 2322 | } | 
| Howard Hinnant | 15476f3 | 2010-07-28 17:35:27 | [diff] [blame] | 2323 | if (!__traits_.isctype(__ch2.first, __neg_mask_) && | 
|  | 2324 | !__traits_.isctype(__ch2.second, __neg_mask_)) | 
|  | 2325 | { | 
|  | 2326 | __found = true; | 
|  | 2327 | goto __exit; | 
|  | 2328 | } | 
| Howard Hinnant | 173968a | 2010-07-13 21:48:06 | [diff] [blame] | 2329 | goto __exit; | 
|  | 2330 | } | 
| Howard Hinnant | 173968a | 2010-07-13 21:48:06 | [diff] [blame] | 2331 | } | 
|  | 2332 | } | 
|  | 2333 | // test *__s.__current_ as not a digraph | 
|  | 2334 | _CharT __ch = *__s.__current_; | 
|  | 2335 | if (__icase_) | 
|  | 2336 | __ch = __traits_.translate_nocase(__ch); | 
|  | 2337 | else if (__collate_) | 
|  | 2338 | __ch = __traits_.translate(__ch); | 
|  | 2339 | for (size_t __i = 0; __i < __chars_.size(); ++__i) | 
|  | 2340 | { | 
|  | 2341 | if (__ch == __chars_[__i]) | 
|  | 2342 | { | 
|  | 2343 | __found = true; | 
|  | 2344 | goto __exit; | 
|  | 2345 | } | 
|  | 2346 | } | 
| Howard Hinnant | 15476f3 | 2010-07-28 17:35:27 | [diff] [blame] | 2347 | if (!__neg_chars_.empty()) | 
|  | 2348 | { | 
|  | 2349 | for (size_t __i = 0; __i < __neg_chars_.size(); ++__i) | 
|  | 2350 | { | 
|  | 2351 | if (__ch == __neg_chars_[__i]) | 
|  | 2352 | goto __is_neg_char; | 
|  | 2353 | } | 
|  | 2354 | __found = true; | 
|  | 2355 | goto __exit; | 
|  | 2356 | } | 
|  | 2357 | __is_neg_char: | 
| Howard Hinnant | 173968a | 2010-07-13 21:48:06 | [diff] [blame] | 2358 | if (!__ranges_.empty()) | 
|  | 2359 | { | 
|  | 2360 | string_type __s2 = __collate_ ? | 
|  | 2361 | __traits_.transform(&__ch, &__ch + 1) : | 
|  | 2362 | string_type(1, __ch); | 
|  | 2363 | for (size_t __i = 0; __i < __ranges_.size(); ++__i) | 
|  | 2364 | { | 
|  | 2365 | if (__ranges_[__i].first <= __s2 && __s2 <= __ranges_[__i].second) | 
|  | 2366 | { | 
|  | 2367 | __found = true; | 
|  | 2368 | goto __exit; | 
|  | 2369 | } | 
|  | 2370 | } | 
|  | 2371 | } | 
|  | 2372 | if (!__equivalences_.empty()) | 
|  | 2373 | { | 
|  | 2374 | string_type __s2 = __traits_.transform_primary(&__ch, &__ch + 1); | 
|  | 2375 | for (size_t __i = 0; __i < __equivalences_.size(); ++__i) | 
|  | 2376 | { | 
|  | 2377 | if (__s2 == __equivalences_[__i]) | 
|  | 2378 | { | 
|  | 2379 | __found = true; | 
|  | 2380 | goto __exit; | 
|  | 2381 | } | 
|  | 2382 | } | 
|  | 2383 | } | 
|  | 2384 | if (__traits_.isctype(__ch, __mask_)) | 
| Howard Hinnant | 15476f3 | 2010-07-28 17:35:27 | [diff] [blame] | 2385 | { | 
| Howard Hinnant | 173968a | 2010-07-13 21:48:06 | [diff] [blame] | 2386 | __found = true; | 
| Howard Hinnant | 15476f3 | 2010-07-28 17:35:27 | [diff] [blame] | 2387 | goto __exit; | 
|  | 2388 | } | 
|  | 2389 | if (__neg_mask_ && !__traits_.isctype(__ch, __neg_mask_)) | 
|  | 2390 | { | 
|  | 2391 | __found = true; | 
|  | 2392 | goto __exit; | 
|  | 2393 | } | 
| Howard Hinnant | 173968a | 2010-07-13 21:48:06 | [diff] [blame] | 2394 | } | 
|  | 2395 | else | 
|  | 2396 | __found = __negate_; // force reject | 
|  | 2397 | __exit: | 
|  | 2398 | if (__found != __negate_) | 
|  | 2399 | { | 
| Howard Hinnant | 173968a | 2010-07-13 21:48:06 | [diff] [blame] | 2400 | __s.__do_ = __state::__accept_and_consume; | 
|  | 2401 | __s.__current_ += __consumed; | 
|  | 2402 | __s.__node_ = this->first(); | 
|  | 2403 | } | 
|  | 2404 | else | 
|  | 2405 | { | 
|  | 2406 | __s.__do_ = __state::__reject; | 
|  | 2407 | __s.__node_ = nullptr; | 
|  | 2408 | } | 
|  | 2409 | } | 
|  | 2410 |  | 
| Howard Hinnant | 2b1b2d4 | 2011-06-14 19:58:17 | [diff] [blame] | 2411 | template <class _CharT, class _Traits> class __lookahead; | 
| Howard Hinnant | 9b80f2b | 2010-06-30 17:22:19 | [diff] [blame] | 2412 |  | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 2413 | template <class _CharT, class _Traits = regex_traits<_CharT> > | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 2414 | class _LIBCPP_VISIBLE basic_regex | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 2415 | { | 
|  | 2416 | public: | 
|  | 2417 | // types: | 
|  | 2418 | typedef _CharT value_type; | 
|  | 2419 | typedef regex_constants::syntax_option_type flag_type; | 
|  | 2420 | typedef typename _Traits::locale_type locale_type; | 
|  | 2421 |  | 
|  | 2422 | private: | 
|  | 2423 | _Traits __traits_; | 
|  | 2424 | flag_type __flags_; | 
|  | 2425 | unsigned __marked_count_; | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 2426 | unsigned __loop_count_; | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 2427 | int __open_count_; | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 2428 | shared_ptr<__empty_state<_CharT> > __start_; | 
|  | 2429 | __owns_one_state<_CharT>* __end_; | 
|  | 2430 |  | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 2431 | typedef _VSTD::__state<_CharT> __state; | 
|  | 2432 | typedef _VSTD::__node<_CharT> __node; | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 2433 |  | 
|  | 2434 | public: | 
|  | 2435 | // constants: | 
| Howard Hinnant | 46623a0 | 2012-07-21 01:31:58 | [diff] [blame] | 2436 | static const regex_constants::syntax_option_type icase = regex_constants::icase; | 
|  | 2437 | static const regex_constants::syntax_option_type nosubs = regex_constants::nosubs; | 
|  | 2438 | static const regex_constants::syntax_option_type optimize = regex_constants::optimize; | 
|  | 2439 | static const regex_constants::syntax_option_type collate = regex_constants::collate; | 
|  | 2440 | static const regex_constants::syntax_option_type ECMAScript = regex_constants::ECMAScript; | 
|  | 2441 | static const regex_constants::syntax_option_type basic = regex_constants::basic; | 
|  | 2442 | static const regex_constants::syntax_option_type extended = regex_constants::extended; | 
|  | 2443 | static const regex_constants::syntax_option_type awk = regex_constants::awk; | 
|  | 2444 | static const regex_constants::syntax_option_type grep = regex_constants::grep; | 
|  | 2445 | static const regex_constants::syntax_option_type egrep = regex_constants::egrep; | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 2446 |  | 
|  | 2447 | // construct/copy/destroy: | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 2448 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 2449 | basic_regex() | 
| Howard Hinnant | 37f9f9c | 2010-07-09 00:15:26 | [diff] [blame] | 2450 | : __flags_(), __marked_count_(0), __loop_count_(0), __open_count_(0), | 
| Howard Hinnant | 41fb6e1 | 2011-03-26 20:02:27 | [diff] [blame] | 2451 | __end_(0) | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 2452 | {} | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 2453 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 2454 | explicit basic_regex(const value_type* __p, flag_type __f = regex_constants::ECMAScript) | 
| Howard Hinnant | 37f9f9c | 2010-07-09 00:15:26 | [diff] [blame] | 2455 | : __flags_(__f), __marked_count_(0), __loop_count_(0), __open_count_(0), | 
| Howard Hinnant | 41fb6e1 | 2011-03-26 20:02:27 | [diff] [blame] | 2456 | __end_(0) | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 2457 | {__parse(__p, __p + __traits_.length(__p));} | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 2458 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 2459 | basic_regex(const value_type* __p, size_t __len, flag_type __f) | 
| Howard Hinnant | 37f9f9c | 2010-07-09 00:15:26 | [diff] [blame] | 2460 | : __flags_(__f), __marked_count_(0), __loop_count_(0), __open_count_(0), | 
| Howard Hinnant | 41fb6e1 | 2011-03-26 20:02:27 | [diff] [blame] | 2461 | __end_(0) | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 2462 | {__parse(__p, __p + __len);} | 
| Howard Hinnant | e9de5ff | 2010-07-27 22:20:32 | [diff] [blame] | 2463 | // basic_regex(const basic_regex&) = default; | 
|  | 2464 | // basic_regex(basic_regex&&) = default; | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 2465 | template <class _ST, class _SA> | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 2466 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 2467 | explicit basic_regex(const basic_string<value_type, _ST, _SA>& __p, | 
|  | 2468 | flag_type __f = regex_constants::ECMAScript) | 
| Howard Hinnant | 37f9f9c | 2010-07-09 00:15:26 | [diff] [blame] | 2469 | : __flags_(__f), __marked_count_(0), __loop_count_(0), __open_count_(0), | 
| Howard Hinnant | 41fb6e1 | 2011-03-26 20:02:27 | [diff] [blame] | 2470 | __end_(0) | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 2471 | {__parse(__p.begin(), __p.end());} | 
|  | 2472 | template <class _ForwardIterator> | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 2473 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 2474 | basic_regex(_ForwardIterator __first, _ForwardIterator __last, | 
|  | 2475 | flag_type __f = regex_constants::ECMAScript) | 
| Howard Hinnant | 37f9f9c | 2010-07-09 00:15:26 | [diff] [blame] | 2476 | : __flags_(__f), __marked_count_(0), __loop_count_(0), __open_count_(0), | 
| Howard Hinnant | 41fb6e1 | 2011-03-26 20:02:27 | [diff] [blame] | 2477 | __end_(0) | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 2478 | {__parse(__first, __last);} | 
| Howard Hinnant | e3e3291 | 2011-08-12 21:56:02 | [diff] [blame] | 2479 | #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 2480 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 2481 | basic_regex(initializer_list<value_type> __il, | 
|  | 2482 | flag_type __f = regex_constants::ECMAScript) | 
| Howard Hinnant | 37f9f9c | 2010-07-09 00:15:26 | [diff] [blame] | 2483 | : __flags_(__f), __marked_count_(0), __loop_count_(0), __open_count_(0), | 
| Howard Hinnant | 41fb6e1 | 2011-03-26 20:02:27 | [diff] [blame] | 2484 | __end_(0) | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 2485 | {__parse(__il.begin(), __il.end());} | 
| Howard Hinnant | e3e3291 | 2011-08-12 21:56:02 | [diff] [blame] | 2486 | #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 2487 |  | 
| Howard Hinnant | 7026a17 | 2010-08-13 18:11:23 | [diff] [blame] | 2488 | // ~basic_regex() = default; | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 2489 |  | 
| Howard Hinnant | e9de5ff | 2010-07-27 22:20:32 | [diff] [blame] | 2490 | // basic_regex& operator=(const basic_regex&) = default; | 
|  | 2491 | // basic_regex& operator=(basic_regex&&) = default; | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 2492 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 7026a17 | 2010-08-13 18:11:23 | [diff] [blame] | 2493 | basic_regex& operator=(const value_type* __p) | 
|  | 2494 | {return assign(__p);} | 
| Howard Hinnant | e3e3291 | 2011-08-12 21:56:02 | [diff] [blame] | 2495 | #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 2496 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 7026a17 | 2010-08-13 18:11:23 | [diff] [blame] | 2497 | basic_regex& operator=(initializer_list<value_type> __il) | 
|  | 2498 | {return assign(__il);} | 
| Howard Hinnant | e3e3291 | 2011-08-12 21:56:02 | [diff] [blame] | 2499 | #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 2500 | template <class _ST, class _SA> | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 2501 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 7026a17 | 2010-08-13 18:11:23 | [diff] [blame] | 2502 | basic_regex& operator=(const basic_string<value_type, _ST, _SA>& __p) | 
|  | 2503 | {return assign(__p);} | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 2504 |  | 
|  | 2505 | // assign: | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 2506 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 7026a17 | 2010-08-13 18:11:23 | [diff] [blame] | 2507 | basic_regex& assign(const basic_regex& __that) | 
|  | 2508 | {return *this = __that;} | 
| Howard Hinnant | 46623a0 | 2012-07-21 01:31:58 | [diff] [blame] | 2509 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
|  | 2510 | _LIBCPP_INLINE_VISIBILITY | 
|  | 2511 | basic_regex& assign(basic_regex&& __that) _NOEXCEPT | 
|  | 2512 | {return *this = _VSTD::move(__that);} | 
|  | 2513 | #endif | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 2514 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 7026a17 | 2010-08-13 18:11:23 | [diff] [blame] | 2515 | basic_regex& assign(const value_type* __p, flag_type __f = regex_constants::ECMAScript) | 
|  | 2516 | {return assign(__p, __p + __traits_.length(__p), __f);} | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 2517 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 7026a17 | 2010-08-13 18:11:23 | [diff] [blame] | 2518 | basic_regex& assign(const value_type* __p, size_t __len, flag_type __f) | 
|  | 2519 | {return assign(__p, __p + __len, __f);} | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 2520 | template <class _ST, class _SA> | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 2521 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 2522 | basic_regex& assign(const basic_string<value_type, _ST, _SA>& __s, | 
| Howard Hinnant | 7026a17 | 2010-08-13 18:11:23 | [diff] [blame] | 2523 | flag_type __f = regex_constants::ECMAScript) | 
|  | 2524 | {return assign(__s.begin(), __s.end(), __f);} | 
|  | 2525 |  | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 2526 | template <class _InputIterator> | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 2527 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 7026a17 | 2010-08-13 18:11:23 | [diff] [blame] | 2528 | typename enable_if | 
|  | 2529 | < | 
|  | 2530 | __is_input_iterator <_InputIterator>::value && | 
|  | 2531 | !__is_forward_iterator<_InputIterator>::value, | 
|  | 2532 | basic_regex& | 
|  | 2533 | >::type | 
|  | 2534 | assign(_InputIterator __first, _InputIterator __last, | 
|  | 2535 | flag_type __f = regex_constants::ECMAScript) | 
|  | 2536 | { | 
|  | 2537 | basic_string<_CharT> __t(__first, __last); | 
|  | 2538 | return assign(__t.begin(), __t.end(), __f); | 
|  | 2539 | } | 
|  | 2540 |  | 
|  | 2541 | private: | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 2542 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 7026a17 | 2010-08-13 18:11:23 | [diff] [blame] | 2543 | void __member_init(flag_type __f) | 
|  | 2544 | { | 
|  | 2545 | __flags_ = __f; | 
|  | 2546 | __marked_count_ = 0; | 
|  | 2547 | __loop_count_ = 0; | 
|  | 2548 | __open_count_ = 0; | 
|  | 2549 | __end_ = nullptr; | 
| Howard Hinnant | 7026a17 | 2010-08-13 18:11:23 | [diff] [blame] | 2550 | } | 
|  | 2551 | public: | 
|  | 2552 |  | 
|  | 2553 | template <class _ForwardIterator> | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 2554 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 7026a17 | 2010-08-13 18:11:23 | [diff] [blame] | 2555 | typename enable_if | 
|  | 2556 | < | 
|  | 2557 | __is_forward_iterator<_ForwardIterator>::value, | 
|  | 2558 | basic_regex& | 
|  | 2559 | >::type | 
|  | 2560 | assign(_ForwardIterator __first, _ForwardIterator __last, | 
|  | 2561 | flag_type __f = regex_constants::ECMAScript) | 
|  | 2562 | { | 
|  | 2563 | __member_init(__f); | 
|  | 2564 | __parse(__first, __last); | 
| Argyrios Kyrtzidis | 1dc6f7a | 2012-10-13 02:03:45 | [diff] [blame] | 2565 | return *this; | 
| Howard Hinnant | 7026a17 | 2010-08-13 18:11:23 | [diff] [blame] | 2566 | } | 
|  | 2567 |  | 
| Howard Hinnant | e3e3291 | 2011-08-12 21:56:02 | [diff] [blame] | 2568 | #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS | 
|  | 2569 |  | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 2570 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 2571 | basic_regex& assign(initializer_list<value_type> __il, | 
| Howard Hinnant | 7026a17 | 2010-08-13 18:11:23 | [diff] [blame] | 2572 | flag_type __f = regex_constants::ECMAScript) | 
|  | 2573 | {return assign(__il.begin(), __il.end(), __f);} | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 2574 |  | 
| Howard Hinnant | e3e3291 | 2011-08-12 21:56:02 | [diff] [blame] | 2575 | #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS | 
|  | 2576 |  | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 2577 | // const operations: | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 2578 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 2579 | unsigned mark_count() const {return __marked_count_;} | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 2580 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 2581 | flag_type flags() const {return __flags_;} | 
|  | 2582 |  | 
|  | 2583 | // locale: | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 2584 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 7026a17 | 2010-08-13 18:11:23 | [diff] [blame] | 2585 | locale_type imbue(locale_type __loc) | 
|  | 2586 | { | 
|  | 2587 | __member_init(ECMAScript); | 
|  | 2588 | __start_.reset(); | 
|  | 2589 | return __traits_.imbue(__loc); | 
|  | 2590 | } | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 2591 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 2592 | locale_type getloc() const {return __traits_.getloc();} | 
|  | 2593 |  | 
|  | 2594 | // swap: | 
| Howard Hinnant | 7026a17 | 2010-08-13 18:11:23 | [diff] [blame] | 2595 | void swap(basic_regex& __r); | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 2596 |  | 
|  | 2597 | private: | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 2598 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 2599 | unsigned __loop_count() const {return __loop_count_;} | 
|  | 2600 |  | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 2601 | template <class _ForwardIterator> | 
| Howard Hinnant | e9de5ff | 2010-07-27 22:20:32 | [diff] [blame] | 2602 | _ForwardIterator | 
|  | 2603 | __parse(_ForwardIterator __first, _ForwardIterator __last); | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 2604 | template <class _ForwardIterator> | 
|  | 2605 | _ForwardIterator | 
|  | 2606 | __parse_basic_reg_exp(_ForwardIterator __first, _ForwardIterator __last); | 
|  | 2607 | template <class _ForwardIterator> | 
|  | 2608 | _ForwardIterator | 
|  | 2609 | __parse_RE_expression(_ForwardIterator __first, _ForwardIterator __last); | 
|  | 2610 | template <class _ForwardIterator> | 
|  | 2611 | _ForwardIterator | 
|  | 2612 | __parse_simple_RE(_ForwardIterator __first, _ForwardIterator __last); | 
|  | 2613 | template <class _ForwardIterator> | 
|  | 2614 | _ForwardIterator | 
|  | 2615 | __parse_nondupl_RE(_ForwardIterator __first, _ForwardIterator __last); | 
|  | 2616 | template <class _ForwardIterator> | 
|  | 2617 | _ForwardIterator | 
|  | 2618 | __parse_one_char_or_coll_elem_RE(_ForwardIterator __first, _ForwardIterator __last); | 
|  | 2619 | template <class _ForwardIterator> | 
|  | 2620 | _ForwardIterator | 
|  | 2621 | __parse_Back_open_paren(_ForwardIterator __first, _ForwardIterator __last); | 
|  | 2622 | template <class _ForwardIterator> | 
|  | 2623 | _ForwardIterator | 
|  | 2624 | __parse_Back_close_paren(_ForwardIterator __first, _ForwardIterator __last); | 
|  | 2625 | template <class _ForwardIterator> | 
|  | 2626 | _ForwardIterator | 
|  | 2627 | __parse_Back_open_brace(_ForwardIterator __first, _ForwardIterator __last); | 
|  | 2628 | template <class _ForwardIterator> | 
|  | 2629 | _ForwardIterator | 
|  | 2630 | __parse_Back_close_brace(_ForwardIterator __first, _ForwardIterator __last); | 
|  | 2631 | template <class _ForwardIterator> | 
|  | 2632 | _ForwardIterator | 
|  | 2633 | __parse_BACKREF(_ForwardIterator __first, _ForwardIterator __last); | 
|  | 2634 | template <class _ForwardIterator> | 
|  | 2635 | _ForwardIterator | 
|  | 2636 | __parse_ORD_CHAR(_ForwardIterator __first, _ForwardIterator __last); | 
|  | 2637 | template <class _ForwardIterator> | 
|  | 2638 | _ForwardIterator | 
|  | 2639 | __parse_QUOTED_CHAR(_ForwardIterator __first, _ForwardIterator __last); | 
|  | 2640 | template <class _ForwardIterator> | 
|  | 2641 | _ForwardIterator | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 2642 | __parse_RE_dupl_symbol(_ForwardIterator __first, _ForwardIterator __last, | 
| Howard Hinnant | e77aa5e | 2010-07-08 17:43:58 | [diff] [blame] | 2643 | __owns_one_state<_CharT>* __s, | 
|  | 2644 | unsigned __mexp_begin, unsigned __mexp_end); | 
| Howard Hinnant | 0de86b6 | 2010-06-25 20:56:08 | [diff] [blame] | 2645 | template <class _ForwardIterator> | 
|  | 2646 | _ForwardIterator | 
| Howard Hinnant | aa69808 | 2010-07-16 19:08:36 | [diff] [blame] | 2647 | __parse_ERE_dupl_symbol(_ForwardIterator __first, _ForwardIterator __last, | 
|  | 2648 | __owns_one_state<_CharT>* __s, | 
|  | 2649 | unsigned __mexp_begin, unsigned __mexp_end); | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 2650 | template <class _ForwardIterator> | 
|  | 2651 | _ForwardIterator | 
| Howard Hinnant | 0de86b6 | 2010-06-25 20:56:08 | [diff] [blame] | 2652 | __parse_bracket_expression(_ForwardIterator __first, _ForwardIterator __last); | 
|  | 2653 | template <class _ForwardIterator> | 
|  | 2654 | _ForwardIterator | 
| Howard Hinnant | 173968a | 2010-07-13 21:48:06 | [diff] [blame] | 2655 | __parse_follow_list(_ForwardIterator __first, _ForwardIterator __last, | 
|  | 2656 | __bracket_expression<_CharT, _Traits>* __ml); | 
| Howard Hinnant | 0de86b6 | 2010-06-25 20:56:08 | [diff] [blame] | 2657 | template <class _ForwardIterator> | 
|  | 2658 | _ForwardIterator | 
| Howard Hinnant | 173968a | 2010-07-13 21:48:06 | [diff] [blame] | 2659 | __parse_expression_term(_ForwardIterator __first, _ForwardIterator __last, | 
|  | 2660 | __bracket_expression<_CharT, _Traits>* __ml); | 
| Howard Hinnant | 0de86b6 | 2010-06-25 20:56:08 | [diff] [blame] | 2661 | template <class _ForwardIterator> | 
|  | 2662 | _ForwardIterator | 
| Howard Hinnant | 173968a | 2010-07-13 21:48:06 | [diff] [blame] | 2663 | __parse_equivalence_class(_ForwardIterator __first, _ForwardIterator __last, | 
|  | 2664 | __bracket_expression<_CharT, _Traits>* __ml); | 
| Howard Hinnant | 0de86b6 | 2010-06-25 20:56:08 | [diff] [blame] | 2665 | template <class _ForwardIterator> | 
|  | 2666 | _ForwardIterator | 
| Howard Hinnant | 173968a | 2010-07-13 21:48:06 | [diff] [blame] | 2667 | __parse_character_class(_ForwardIterator __first, _ForwardIterator __last, | 
|  | 2668 | __bracket_expression<_CharT, _Traits>* __ml); | 
| Howard Hinnant | 0de86b6 | 2010-06-25 20:56:08 | [diff] [blame] | 2669 | template <class _ForwardIterator> | 
|  | 2670 | _ForwardIterator | 
| Howard Hinnant | 173968a | 2010-07-13 21:48:06 | [diff] [blame] | 2671 | __parse_collating_symbol(_ForwardIterator __first, _ForwardIterator __last, | 
|  | 2672 | basic_string<_CharT>& __col_sym); | 
| Howard Hinnant | 0de86b6 | 2010-06-25 20:56:08 | [diff] [blame] | 2673 | template <class _ForwardIterator> | 
|  | 2674 | _ForwardIterator | 
|  | 2675 | __parse_DUP_COUNT(_ForwardIterator __first, _ForwardIterator __last, int& __c); | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 2676 | template <class _ForwardIterator> | 
|  | 2677 | _ForwardIterator | 
|  | 2678 | __parse_extended_reg_exp(_ForwardIterator __first, _ForwardIterator __last); | 
|  | 2679 | template <class _ForwardIterator> | 
|  | 2680 | _ForwardIterator | 
|  | 2681 | __parse_ERE_branch(_ForwardIterator __first, _ForwardIterator __last); | 
|  | 2682 | template <class _ForwardIterator> | 
|  | 2683 | _ForwardIterator | 
|  | 2684 | __parse_ERE_expression(_ForwardIterator __first, _ForwardIterator __last); | 
|  | 2685 | template <class _ForwardIterator> | 
|  | 2686 | _ForwardIterator | 
|  | 2687 | __parse_one_char_or_coll_elem_ERE(_ForwardIterator __first, _ForwardIterator __last); | 
|  | 2688 | template <class _ForwardIterator> | 
|  | 2689 | _ForwardIterator | 
|  | 2690 | __parse_ORD_CHAR_ERE(_ForwardIterator __first, _ForwardIterator __last); | 
|  | 2691 | template <class _ForwardIterator> | 
|  | 2692 | _ForwardIterator | 
|  | 2693 | __parse_QUOTED_CHAR_ERE(_ForwardIterator __first, _ForwardIterator __last); | 
| Howard Hinnant | 2ade7c2 | 2010-07-22 17:53:24 | [diff] [blame] | 2694 | template <class _ForwardIterator> | 
|  | 2695 | _ForwardIterator | 
|  | 2696 | __parse_ecma_exp(_ForwardIterator __first, _ForwardIterator __last); | 
|  | 2697 | template <class _ForwardIterator> | 
|  | 2698 | _ForwardIterator | 
|  | 2699 | __parse_alternative(_ForwardIterator __first, _ForwardIterator __last); | 
|  | 2700 | template <class _ForwardIterator> | 
|  | 2701 | _ForwardIterator | 
|  | 2702 | __parse_term(_ForwardIterator __first, _ForwardIterator __last); | 
|  | 2703 | template <class _ForwardIterator> | 
|  | 2704 | _ForwardIterator | 
|  | 2705 | __parse_assertion(_ForwardIterator __first, _ForwardIterator __last); | 
|  | 2706 | template <class _ForwardIterator> | 
|  | 2707 | _ForwardIterator | 
|  | 2708 | __parse_atom(_ForwardIterator __first, _ForwardIterator __last); | 
|  | 2709 | template <class _ForwardIterator> | 
|  | 2710 | _ForwardIterator | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 2711 | __parse_atom_escape(_ForwardIterator __first, _ForwardIterator __last); | 
|  | 2712 | template <class _ForwardIterator> | 
|  | 2713 | _ForwardIterator | 
|  | 2714 | __parse_decimal_escape(_ForwardIterator __first, _ForwardIterator __last); | 
|  | 2715 | template <class _ForwardIterator> | 
|  | 2716 | _ForwardIterator | 
|  | 2717 | __parse_character_class_escape(_ForwardIterator __first, _ForwardIterator __last); | 
|  | 2718 | template <class _ForwardIterator> | 
|  | 2719 | _ForwardIterator | 
| Howard Hinnant | 15476f3 | 2010-07-28 17:35:27 | [diff] [blame] | 2720 | __parse_character_escape(_ForwardIterator __first, _ForwardIterator __last, | 
|  | 2721 | basic_string<_CharT>* __str = nullptr); | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 2722 | template <class _ForwardIterator> | 
|  | 2723 | _ForwardIterator | 
|  | 2724 | __parse_pattern_character(_ForwardIterator __first, _ForwardIterator __last); | 
| Howard Hinnant | 856846b | 2010-07-27 19:53:10 | [diff] [blame] | 2725 | template <class _ForwardIterator> | 
|  | 2726 | _ForwardIterator | 
|  | 2727 | __parse_grep(_ForwardIterator __first, _ForwardIterator __last); | 
|  | 2728 | template <class _ForwardIterator> | 
|  | 2729 | _ForwardIterator | 
|  | 2730 | __parse_egrep(_ForwardIterator __first, _ForwardIterator __last); | 
| Howard Hinnant | 15476f3 | 2010-07-28 17:35:27 | [diff] [blame] | 2731 | template <class _ForwardIterator> | 
|  | 2732 | _ForwardIterator | 
|  | 2733 | __parse_class_escape(_ForwardIterator __first, _ForwardIterator __last, | 
|  | 2734 | basic_string<_CharT>& __str, | 
|  | 2735 | __bracket_expression<_CharT, _Traits>* __ml); | 
|  | 2736 | template <class _ForwardIterator> | 
|  | 2737 | _ForwardIterator | 
|  | 2738 | __parse_awk_escape(_ForwardIterator __first, _ForwardIterator __last, | 
|  | 2739 | basic_string<_CharT>* __str = nullptr); | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 2740 |  | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 2741 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 41fb6e1 | 2011-03-26 20:02:27 | [diff] [blame] | 2742 | void __push_l_anchor(); | 
| Howard Hinnant | 37f9f9c | 2010-07-09 00:15:26 | [diff] [blame] | 2743 | void __push_r_anchor(); | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 2744 | void __push_match_any(); | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 2745 | void __push_match_any_but_newline(); | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 2746 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | e77aa5e | 2010-07-08 17:43:58 | [diff] [blame] | 2747 | void __push_greedy_inf_repeat(size_t __min, __owns_one_state<_CharT>* __s, | 
|  | 2748 | unsigned __mexp_begin = 0, unsigned __mexp_end = 0) | 
|  | 2749 | {__push_loop(__min, numeric_limits<size_t>::max(), __s, | 
|  | 2750 | __mexp_begin, __mexp_end);} | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 2751 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 2752 | void __push_nongreedy_inf_repeat(size_t __min, __owns_one_state<_CharT>* __s, | 
|  | 2753 | unsigned __mexp_begin = 0, unsigned __mexp_end = 0) | 
|  | 2754 | {__push_loop(__min, numeric_limits<size_t>::max(), __s, | 
|  | 2755 | __mexp_begin, __mexp_end, false);} | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 2756 | void __push_loop(size_t __min, size_t __max, __owns_one_state<_CharT>* __s, | 
|  | 2757 | size_t __mexp_begin = 0, size_t __mexp_end = 0, | 
|  | 2758 | bool __greedy = true); | 
| Howard Hinnant | 173968a | 2010-07-13 21:48:06 | [diff] [blame] | 2759 | __bracket_expression<_CharT, _Traits>* __start_matching_list(bool __negate); | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 2760 | void __push_char(value_type __c); | 
| Howard Hinnant | cba352d | 2010-07-12 18:16:05 | [diff] [blame] | 2761 | void __push_back_ref(int __i); | 
| Howard Hinnant | aa69808 | 2010-07-16 19:08:36 | [diff] [blame] | 2762 | void __push_alternation(__owns_one_state<_CharT>* __sa, | 
|  | 2763 | __owns_one_state<_CharT>* __sb); | 
| Howard Hinnant | 0dca5fc | 2010-06-30 20:30:19 | [diff] [blame] | 2764 | void __push_begin_marked_subexpression(); | 
|  | 2765 | void __push_end_marked_subexpression(unsigned); | 
| Howard Hinnant | 2ade7c2 | 2010-07-22 17:53:24 | [diff] [blame] | 2766 | void __push_empty(); | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 2767 | void __push_word_boundary(bool); | 
| Howard Hinnant | e9de5ff | 2010-07-27 22:20:32 | [diff] [blame] | 2768 | void __push_lookahead(const basic_regex&, bool); | 
| Howard Hinnant | 9b80f2b | 2010-06-30 17:22:19 | [diff] [blame] | 2769 |  | 
| Howard Hinnant | 22ce0b4 | 2010-07-14 21:14:52 | [diff] [blame] | 2770 | template <class _Allocator> | 
| Howard Hinnant | 9b80f2b | 2010-06-30 17:22:19 | [diff] [blame] | 2771 | bool | 
| Howard Hinnant | 22ce0b4 | 2010-07-14 21:14:52 | [diff] [blame] | 2772 | __search(const _CharT* __first, const _CharT* __last, | 
|  | 2773 | match_results<const _CharT*, _Allocator>& __m, | 
| Howard Hinnant | 9b80f2b | 2010-06-30 17:22:19 | [diff] [blame] | 2774 | regex_constants::match_flag_type __flags) const; | 
|  | 2775 |  | 
| Howard Hinnant | 22ce0b4 | 2010-07-14 21:14:52 | [diff] [blame] | 2776 | template <class _Allocator> | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 2777 | bool | 
| Howard Hinnant | 22ce0b4 | 2010-07-14 21:14:52 | [diff] [blame] | 2778 | __match_at_start(const _CharT* __first, const _CharT* __last, | 
|  | 2779 | match_results<const _CharT*, _Allocator>& __m, | 
| Howard Hinnant | 41fb6e1 | 2011-03-26 20:02:27 | [diff] [blame] | 2780 | regex_constants::match_flag_type __flags, bool) const; | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 2781 | template <class _Allocator> | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 2782 | bool | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 2783 | __match_at_start_ecma(const _CharT* __first, const _CharT* __last, | 
|  | 2784 | match_results<const _CharT*, _Allocator>& __m, | 
| Howard Hinnant | 41fb6e1 | 2011-03-26 20:02:27 | [diff] [blame] | 2785 | regex_constants::match_flag_type __flags, bool) const; | 
| Howard Hinnant | 22ce0b4 | 2010-07-14 21:14:52 | [diff] [blame] | 2786 | template <class _Allocator> | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 2787 | bool | 
|  | 2788 | __match_at_start_posix_nosubs(const _CharT* __first, const _CharT* __last, | 
| Howard Hinnant | 22ce0b4 | 2010-07-14 21:14:52 | [diff] [blame] | 2789 | match_results<const _CharT*, _Allocator>& __m, | 
| Howard Hinnant | 41fb6e1 | 2011-03-26 20:02:27 | [diff] [blame] | 2790 | regex_constants::match_flag_type __flags, bool) const; | 
| Howard Hinnant | 22ce0b4 | 2010-07-14 21:14:52 | [diff] [blame] | 2791 | template <class _Allocator> | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 2792 | bool | 
| Howard Hinnant | 22ce0b4 | 2010-07-14 21:14:52 | [diff] [blame] | 2793 | __match_at_start_posix_subs(const _CharT* __first, const _CharT* __last, | 
|  | 2794 | match_results<const _CharT*, _Allocator>& __m, | 
| Howard Hinnant | 41fb6e1 | 2011-03-26 20:02:27 | [diff] [blame] | 2795 | regex_constants::match_flag_type __flags, bool) const; | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 2796 |  | 
| Howard Hinnant | 9996844 | 2011-11-29 18:15:50 | [diff] [blame] | 2797 | template <class _Bp, class _Ap, class _Cp, class _Tp> | 
| Howard Hinnant | 9b80f2b | 2010-06-30 17:22:19 | [diff] [blame] | 2798 | friend | 
|  | 2799 | bool | 
| Howard Hinnant | 9996844 | 2011-11-29 18:15:50 | [diff] [blame] | 2800 | regex_search(_Bp, _Bp, match_results<_Bp, _Ap>&, const basic_regex<_Cp, _Tp>&, | 
| Howard Hinnant | 9b80f2b | 2010-06-30 17:22:19 | [diff] [blame] | 2801 | regex_constants::match_flag_type); | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 2802 |  | 
| Howard Hinnant | 9996844 | 2011-11-29 18:15:50 | [diff] [blame] | 2803 | template <class _Ap, class _Cp, class _Tp> | 
| Howard Hinnant | 22ce0b4 | 2010-07-14 21:14:52 | [diff] [blame] | 2804 | friend | 
|  | 2805 | bool | 
| Howard Hinnant | 9996844 | 2011-11-29 18:15:50 | [diff] [blame] | 2806 | regex_search(const _Cp*, const _Cp*, match_results<const _Cp*, _Ap>&, | 
|  | 2807 | const basic_regex<_Cp, _Tp>&, regex_constants::match_flag_type); | 
| Howard Hinnant | 22ce0b4 | 2010-07-14 21:14:52 | [diff] [blame] | 2808 |  | 
| Howard Hinnant | 9996844 | 2011-11-29 18:15:50 | [diff] [blame] | 2809 | template <class _Bp, class _Cp, class _Tp> | 
| Howard Hinnant | 22ce0b4 | 2010-07-14 21:14:52 | [diff] [blame] | 2810 | friend | 
|  | 2811 | bool | 
| Howard Hinnant | 9996844 | 2011-11-29 18:15:50 | [diff] [blame] | 2812 | regex_search(_Bp, _Bp, const basic_regex<_Cp, _Tp>&, | 
| Howard Hinnant | 22ce0b4 | 2010-07-14 21:14:52 | [diff] [blame] | 2813 | regex_constants::match_flag_type); | 
|  | 2814 |  | 
| Howard Hinnant | 9996844 | 2011-11-29 18:15:50 | [diff] [blame] | 2815 | template <class _Cp, class _Tp> | 
| Howard Hinnant | 22ce0b4 | 2010-07-14 21:14:52 | [diff] [blame] | 2816 | friend | 
|  | 2817 | bool | 
| Howard Hinnant | 9996844 | 2011-11-29 18:15:50 | [diff] [blame] | 2818 | regex_search(const _Cp*, const _Cp*, | 
|  | 2819 | const basic_regex<_Cp, _Tp>&, regex_constants::match_flag_type); | 
| Howard Hinnant | 22ce0b4 | 2010-07-14 21:14:52 | [diff] [blame] | 2820 |  | 
| Howard Hinnant | 9996844 | 2011-11-29 18:15:50 | [diff] [blame] | 2821 | template <class _Cp, class _Ap, class _Tp> | 
| Howard Hinnant | 22ce0b4 | 2010-07-14 21:14:52 | [diff] [blame] | 2822 | friend | 
|  | 2823 | bool | 
| Howard Hinnant | 9996844 | 2011-11-29 18:15:50 | [diff] [blame] | 2824 | regex_search(const _Cp*, match_results<const _Cp*, _Ap>&, const basic_regex<_Cp, _Tp>&, | 
| Howard Hinnant | 22ce0b4 | 2010-07-14 21:14:52 | [diff] [blame] | 2825 | regex_constants::match_flag_type); | 
|  | 2826 |  | 
| Howard Hinnant | 9996844 | 2011-11-29 18:15:50 | [diff] [blame] | 2827 | template <class _ST, class _SA, class _Cp, class _Tp> | 
| Howard Hinnant | 22ce0b4 | 2010-07-14 21:14:52 | [diff] [blame] | 2828 | friend | 
|  | 2829 | bool | 
| Howard Hinnant | 9996844 | 2011-11-29 18:15:50 | [diff] [blame] | 2830 | regex_search(const basic_string<_Cp, _ST, _SA>& __s, | 
|  | 2831 | const basic_regex<_Cp, _Tp>& __e, | 
| Howard Hinnant | 22ce0b4 | 2010-07-14 21:14:52 | [diff] [blame] | 2832 | regex_constants::match_flag_type __flags); | 
|  | 2833 |  | 
| Howard Hinnant | 9996844 | 2011-11-29 18:15:50 | [diff] [blame] | 2834 | template <class _ST, class _SA, class _Ap, class _Cp, class _Tp> | 
| Howard Hinnant | 22ce0b4 | 2010-07-14 21:14:52 | [diff] [blame] | 2835 | friend | 
|  | 2836 | bool | 
| Howard Hinnant | 9996844 | 2011-11-29 18:15:50 | [diff] [blame] | 2837 | regex_search(const basic_string<_Cp, _ST, _SA>& __s, | 
|  | 2838 | match_results<typename basic_string<_Cp, _ST, _SA>::const_iterator, _Ap>&, | 
|  | 2839 | const basic_regex<_Cp, _Tp>& __e, | 
| Howard Hinnant | 22ce0b4 | 2010-07-14 21:14:52 | [diff] [blame] | 2840 | regex_constants::match_flag_type __flags); | 
| Howard Hinnant | e9de5ff | 2010-07-27 22:20:32 | [diff] [blame] | 2841 |  | 
|  | 2842 | template <class, class> friend class __lookahead; | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 2843 | }; | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 2844 |  | 
|  | 2845 | template <class _CharT, class _Traits> | 
| Howard Hinnant | 7026a17 | 2010-08-13 18:11:23 | [diff] [blame] | 2846 | void | 
|  | 2847 | basic_regex<_CharT, _Traits>::swap(basic_regex& __r) | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 2848 | { | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 2849 | using _VSTD::swap; | 
| Howard Hinnant | 7026a17 | 2010-08-13 18:11:23 | [diff] [blame] | 2850 | swap(__traits_, __r.__traits_); | 
|  | 2851 | swap(__flags_, __r.__flags_); | 
|  | 2852 | swap(__marked_count_, __r.__marked_count_); | 
|  | 2853 | swap(__loop_count_, __r.__loop_count_); | 
|  | 2854 | swap(__open_count_, __r.__open_count_); | 
|  | 2855 | swap(__start_, __r.__start_); | 
|  | 2856 | swap(__end_, __r.__end_); | 
| Howard Hinnant | 7026a17 | 2010-08-13 18:11:23 | [diff] [blame] | 2857 | } | 
|  | 2858 |  | 
|  | 2859 | template <class _CharT, class _Traits> | 
|  | 2860 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 2861 | void | 
|  | 2862 | swap(basic_regex<_CharT, _Traits>& __x, basic_regex<_CharT, _Traits>& __y) | 
|  | 2863 | { | 
|  | 2864 | return __x.swap(__y); | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 2865 | } | 
|  | 2866 |  | 
| Howard Hinnant | e9de5ff | 2010-07-27 22:20:32 | [diff] [blame] | 2867 | // __lookahead | 
|  | 2868 |  | 
|  | 2869 | template <class _CharT, class _Traits> | 
|  | 2870 | class __lookahead | 
|  | 2871 | : public __owns_one_state<_CharT> | 
|  | 2872 | { | 
|  | 2873 | typedef __owns_one_state<_CharT> base; | 
|  | 2874 |  | 
|  | 2875 | basic_regex<_CharT, _Traits> __exp_; | 
|  | 2876 | bool __invert_; | 
|  | 2877 |  | 
|  | 2878 | __lookahead(const __lookahead&); | 
|  | 2879 | __lookahead& operator=(const __lookahead&); | 
|  | 2880 | public: | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 2881 | typedef _VSTD::__state<_CharT> __state; | 
| Howard Hinnant | e9de5ff | 2010-07-27 22:20:32 | [diff] [blame] | 2882 |  | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 2883 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | e9de5ff | 2010-07-27 22:20:32 | [diff] [blame] | 2884 | __lookahead(const basic_regex<_CharT, _Traits>& __exp, bool __invert, __node<_CharT>* __s) | 
|  | 2885 | : base(__s), __exp_(__exp), __invert_(__invert) {} | 
|  | 2886 |  | 
|  | 2887 | virtual void __exec(__state&) const; | 
| Howard Hinnant | e9de5ff | 2010-07-27 22:20:32 | [diff] [blame] | 2888 | }; | 
|  | 2889 |  | 
|  | 2890 | template <class _CharT, class _Traits> | 
|  | 2891 | void | 
|  | 2892 | __lookahead<_CharT, _Traits>::__exec(__state& __s) const | 
|  | 2893 | { | 
|  | 2894 | match_results<const _CharT*> __m; | 
|  | 2895 | __m.__init(1 + __exp_.mark_count(), __s.__current_, __s.__last_); | 
|  | 2896 | bool __matched = __exp_.__match_at_start_ecma(__s.__current_, __s.__last_, | 
| Howard Hinnant | 41fb6e1 | 2011-03-26 20:02:27 | [diff] [blame] | 2897 | __m, | 
|  | 2898 | __s.__flags_ | regex_constants::match_continuous, | 
|  | 2899 | true); | 
| Howard Hinnant | e9de5ff | 2010-07-27 22:20:32 | [diff] [blame] | 2900 | if (__matched != __invert_) | 
|  | 2901 | { | 
|  | 2902 | __s.__do_ = __state::__accept_but_not_consume; | 
|  | 2903 | __s.__node_ = this->first(); | 
|  | 2904 | } | 
|  | 2905 | else | 
|  | 2906 | { | 
|  | 2907 | __s.__do_ = __state::__reject; | 
|  | 2908 | __s.__node_ = nullptr; | 
|  | 2909 | } | 
|  | 2910 | } | 
|  | 2911 |  | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 2912 | template <class _CharT, class _Traits> | 
|  | 2913 | template <class _ForwardIterator> | 
| Howard Hinnant | e9de5ff | 2010-07-27 22:20:32 | [diff] [blame] | 2914 | _ForwardIterator | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 2915 | basic_regex<_CharT, _Traits>::__parse(_ForwardIterator __first, | 
|  | 2916 | _ForwardIterator __last) | 
|  | 2917 | { | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 2918 | { | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 2919 | unique_ptr<__node> __h(new __end_state<_CharT>); | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 2920 | __start_.reset(new __empty_state<_CharT>(__h.get())); | 
|  | 2921 | __h.release(); | 
|  | 2922 | __end_ = __start_.get(); | 
|  | 2923 | } | 
| Howard Hinnant | ad2a7ab | 2010-07-27 17:24:17 | [diff] [blame] | 2924 | switch (__flags_ & 0x1F0) | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 2925 | { | 
|  | 2926 | case ECMAScript: | 
| Howard Hinnant | e9de5ff | 2010-07-27 22:20:32 | [diff] [blame] | 2927 | __first = __parse_ecma_exp(__first, __last); | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 2928 | break; | 
|  | 2929 | case basic: | 
| Howard Hinnant | e9de5ff | 2010-07-27 22:20:32 | [diff] [blame] | 2930 | __first = __parse_basic_reg_exp(__first, __last); | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 2931 | break; | 
|  | 2932 | case extended: | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 2933 | case awk: | 
| Howard Hinnant | 15476f3 | 2010-07-28 17:35:27 | [diff] [blame] | 2934 | __first = __parse_extended_reg_exp(__first, __last); | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 2935 | break; | 
|  | 2936 | case grep: | 
| Howard Hinnant | e9de5ff | 2010-07-27 22:20:32 | [diff] [blame] | 2937 | __first = __parse_grep(__first, __last); | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 2938 | break; | 
|  | 2939 | case egrep: | 
| Howard Hinnant | e9de5ff | 2010-07-27 22:20:32 | [diff] [blame] | 2940 | __first = __parse_egrep(__first, __last); | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 2941 | break; | 
| Howard Hinnant | d444470 | 2010-08-11 17:04:31 | [diff] [blame] | 2942 | #ifndef _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 2943 | default: | 
| Howard Hinnant | ad2a7ab | 2010-07-27 17:24:17 | [diff] [blame] | 2944 | throw regex_error(regex_constants::__re_err_grammar); | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 | [diff] [blame] | 2945 | #endif // _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 2946 | } | 
| Howard Hinnant | e9de5ff | 2010-07-27 22:20:32 | [diff] [blame] | 2947 | return __first; | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 2948 | } | 
|  | 2949 |  | 
|  | 2950 | template <class _CharT, class _Traits> | 
|  | 2951 | template <class _ForwardIterator> | 
|  | 2952 | _ForwardIterator | 
|  | 2953 | basic_regex<_CharT, _Traits>::__parse_basic_reg_exp(_ForwardIterator __first, | 
|  | 2954 | _ForwardIterator __last) | 
|  | 2955 | { | 
|  | 2956 | if (__first != __last) | 
|  | 2957 | { | 
|  | 2958 | if (*__first == '^') | 
|  | 2959 | { | 
|  | 2960 | __push_l_anchor(); | 
|  | 2961 | ++__first; | 
|  | 2962 | } | 
|  | 2963 | if (__first != __last) | 
|  | 2964 | { | 
|  | 2965 | __first = __parse_RE_expression(__first, __last); | 
|  | 2966 | if (__first != __last) | 
|  | 2967 | { | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 2968 | _ForwardIterator __temp = _VSTD::next(__first); | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 2969 | if (__temp == __last && *__first == '$') | 
|  | 2970 | { | 
|  | 2971 | __push_r_anchor(); | 
|  | 2972 | ++__first; | 
|  | 2973 | } | 
|  | 2974 | } | 
|  | 2975 | } | 
| Howard Hinnant | d444470 | 2010-08-11 17:04:31 | [diff] [blame] | 2976 | #ifndef _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 2977 | if (__first != __last) | 
| Howard Hinnant | ad2a7ab | 2010-07-27 17:24:17 | [diff] [blame] | 2978 | throw regex_error(regex_constants::__re_err_empty); | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 | [diff] [blame] | 2979 | #endif // _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 2980 | } | 
|  | 2981 | return __first; | 
|  | 2982 | } | 
|  | 2983 |  | 
|  | 2984 | template <class _CharT, class _Traits> | 
|  | 2985 | template <class _ForwardIterator> | 
|  | 2986 | _ForwardIterator | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 2987 | basic_regex<_CharT, _Traits>::__parse_extended_reg_exp(_ForwardIterator __first, | 
|  | 2988 | _ForwardIterator __last) | 
|  | 2989 | { | 
| Howard Hinnant | aa69808 | 2010-07-16 19:08:36 | [diff] [blame] | 2990 | __owns_one_state<_CharT>* __sa = __end_; | 
|  | 2991 | _ForwardIterator __temp = __parse_ERE_branch(__first, __last); | 
| Howard Hinnant | d444470 | 2010-08-11 17:04:31 | [diff] [blame] | 2992 | #ifndef _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | aa69808 | 2010-07-16 19:08:36 | [diff] [blame] | 2993 | if (__temp == __first) | 
| Howard Hinnant | ad2a7ab | 2010-07-27 17:24:17 | [diff] [blame] | 2994 | throw regex_error(regex_constants::__re_err_empty); | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 | [diff] [blame] | 2995 | #endif // _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | aa69808 | 2010-07-16 19:08:36 | [diff] [blame] | 2996 | __first = __temp; | 
|  | 2997 | while (__first != __last && *__first == '|') | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 2998 | { | 
| Howard Hinnant | aa69808 | 2010-07-16 19:08:36 | [diff] [blame] | 2999 | __owns_one_state<_CharT>* __sb = __end_; | 
|  | 3000 | __temp = __parse_ERE_branch(++__first, __last); | 
| Howard Hinnant | d444470 | 2010-08-11 17:04:31 | [diff] [blame] | 3001 | #ifndef _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 3002 | if (__temp == __first) | 
| Howard Hinnant | ad2a7ab | 2010-07-27 17:24:17 | [diff] [blame] | 3003 | throw regex_error(regex_constants::__re_err_empty); | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 | [diff] [blame] | 3004 | #endif // _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | aa69808 | 2010-07-16 19:08:36 | [diff] [blame] | 3005 | __push_alternation(__sa, __sb); | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 3006 | __first = __temp; | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 3007 | } | 
|  | 3008 | return __first; | 
|  | 3009 | } | 
|  | 3010 |  | 
|  | 3011 | template <class _CharT, class _Traits> | 
|  | 3012 | template <class _ForwardIterator> | 
|  | 3013 | _ForwardIterator | 
|  | 3014 | basic_regex<_CharT, _Traits>::__parse_ERE_branch(_ForwardIterator __first, | 
|  | 3015 | _ForwardIterator __last) | 
|  | 3016 | { | 
|  | 3017 | _ForwardIterator __temp = __parse_ERE_expression(__first, __last); | 
| Howard Hinnant | d444470 | 2010-08-11 17:04:31 | [diff] [blame] | 3018 | #ifndef _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 3019 | if (__temp == __first) | 
| Howard Hinnant | ad2a7ab | 2010-07-27 17:24:17 | [diff] [blame] | 3020 | throw regex_error(regex_constants::__re_err_empty); | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 | [diff] [blame] | 3021 | #endif // _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 3022 | do | 
|  | 3023 | { | 
|  | 3024 | __first = __temp; | 
|  | 3025 | __temp = __parse_ERE_expression(__first, __last); | 
|  | 3026 | } while (__temp != __first); | 
|  | 3027 | return __first; | 
|  | 3028 | } | 
|  | 3029 |  | 
|  | 3030 | template <class _CharT, class _Traits> | 
|  | 3031 | template <class _ForwardIterator> | 
|  | 3032 | _ForwardIterator | 
|  | 3033 | basic_regex<_CharT, _Traits>::__parse_ERE_expression(_ForwardIterator __first, | 
|  | 3034 | _ForwardIterator __last) | 
|  | 3035 | { | 
| Howard Hinnant | aa69808 | 2010-07-16 19:08:36 | [diff] [blame] | 3036 | __owns_one_state<_CharT>* __e = __end_; | 
|  | 3037 | unsigned __mexp_begin = __marked_count_; | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 3038 | _ForwardIterator __temp = __parse_one_char_or_coll_elem_ERE(__first, __last); | 
|  | 3039 | if (__temp == __first && __temp != __last) | 
|  | 3040 | { | 
|  | 3041 | switch (*__temp) | 
|  | 3042 | { | 
|  | 3043 | case '^': | 
|  | 3044 | __push_l_anchor(); | 
|  | 3045 | ++__temp; | 
|  | 3046 | break; | 
|  | 3047 | case '$': | 
|  | 3048 | __push_r_anchor(); | 
|  | 3049 | ++__temp; | 
|  | 3050 | break; | 
|  | 3051 | case '(': | 
| Howard Hinnant | 0dca5fc | 2010-06-30 20:30:19 | [diff] [blame] | 3052 | __push_begin_marked_subexpression(); | 
|  | 3053 | unsigned __temp_count = __marked_count_; | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 3054 | ++__open_count_; | 
|  | 3055 | __temp = __parse_extended_reg_exp(++__temp, __last); | 
| Howard Hinnant | d444470 | 2010-08-11 17:04:31 | [diff] [blame] | 3056 | #ifndef _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 3057 | if (__temp == __last || *__temp != ')') | 
|  | 3058 | throw regex_error(regex_constants::error_paren); | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 | [diff] [blame] | 3059 | #endif // _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | 0dca5fc | 2010-06-30 20:30:19 | [diff] [blame] | 3060 | __push_end_marked_subexpression(__temp_count); | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 3061 | --__open_count_; | 
|  | 3062 | ++__temp; | 
|  | 3063 | break; | 
|  | 3064 | } | 
|  | 3065 | } | 
|  | 3066 | if (__temp != __first) | 
| Howard Hinnant | aa69808 | 2010-07-16 19:08:36 | [diff] [blame] | 3067 | __temp = __parse_ERE_dupl_symbol(__temp, __last, __e, __mexp_begin+1, | 
|  | 3068 | __marked_count_+1); | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 3069 | __first = __temp; | 
|  | 3070 | return __first; | 
|  | 3071 | } | 
|  | 3072 |  | 
|  | 3073 | template <class _CharT, class _Traits> | 
|  | 3074 | template <class _ForwardIterator> | 
|  | 3075 | _ForwardIterator | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 3076 | basic_regex<_CharT, _Traits>::__parse_RE_expression(_ForwardIterator __first, | 
|  | 3077 | _ForwardIterator __last) | 
|  | 3078 | { | 
|  | 3079 | while (true) | 
|  | 3080 | { | 
|  | 3081 | _ForwardIterator __temp = __parse_simple_RE(__first, __last); | 
|  | 3082 | if (__temp == __first) | 
|  | 3083 | break; | 
|  | 3084 | __first = __temp; | 
|  | 3085 | } | 
|  | 3086 | return __first; | 
|  | 3087 | } | 
|  | 3088 |  | 
|  | 3089 | template <class _CharT, class _Traits> | 
|  | 3090 | template <class _ForwardIterator> | 
|  | 3091 | _ForwardIterator | 
|  | 3092 | basic_regex<_CharT, _Traits>::__parse_simple_RE(_ForwardIterator __first, | 
|  | 3093 | _ForwardIterator __last) | 
|  | 3094 | { | 
|  | 3095 | if (__first != __last) | 
|  | 3096 | { | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 3097 | __owns_one_state<_CharT>* __e = __end_; | 
| Howard Hinnant | e77aa5e | 2010-07-08 17:43:58 | [diff] [blame] | 3098 | unsigned __mexp_begin = __marked_count_; | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 3099 | _ForwardIterator __temp = __parse_nondupl_RE(__first, __last); | 
|  | 3100 | if (__temp != __first) | 
| Howard Hinnant | e77aa5e | 2010-07-08 17:43:58 | [diff] [blame] | 3101 | __first = __parse_RE_dupl_symbol(__temp, __last, __e, | 
|  | 3102 | __mexp_begin+1, __marked_count_+1); | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 3103 | } | 
|  | 3104 | return __first; | 
|  | 3105 | } | 
|  | 3106 |  | 
|  | 3107 | template <class _CharT, class _Traits> | 
|  | 3108 | template <class _ForwardIterator> | 
|  | 3109 | _ForwardIterator | 
|  | 3110 | basic_regex<_CharT, _Traits>::__parse_nondupl_RE(_ForwardIterator __first, | 
|  | 3111 | _ForwardIterator __last) | 
|  | 3112 | { | 
|  | 3113 | _ForwardIterator __temp = __first; | 
|  | 3114 | __first = __parse_one_char_or_coll_elem_RE(__first, __last); | 
|  | 3115 | if (__temp == __first) | 
|  | 3116 | { | 
|  | 3117 | __temp = __parse_Back_open_paren(__first, __last); | 
|  | 3118 | if (__temp != __first) | 
|  | 3119 | { | 
| Howard Hinnant | 0dca5fc | 2010-06-30 20:30:19 | [diff] [blame] | 3120 | __push_begin_marked_subexpression(); | 
|  | 3121 | unsigned __temp_count = __marked_count_; | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 3122 | __first = __parse_RE_expression(__temp, __last); | 
|  | 3123 | __temp = __parse_Back_close_paren(__first, __last); | 
| Howard Hinnant | d444470 | 2010-08-11 17:04:31 | [diff] [blame] | 3124 | #ifndef _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 3125 | if (__temp == __first) | 
|  | 3126 | throw regex_error(regex_constants::error_paren); | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 | [diff] [blame] | 3127 | #endif // _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | 0dca5fc | 2010-06-30 20:30:19 | [diff] [blame] | 3128 | __push_end_marked_subexpression(__temp_count); | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 3129 | __first = __temp; | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 3130 | } | 
|  | 3131 | else | 
|  | 3132 | __first = __parse_BACKREF(__first, __last); | 
|  | 3133 | } | 
|  | 3134 | return __first; | 
|  | 3135 | } | 
|  | 3136 |  | 
|  | 3137 | template <class _CharT, class _Traits> | 
|  | 3138 | template <class _ForwardIterator> | 
|  | 3139 | _ForwardIterator | 
|  | 3140 | basic_regex<_CharT, _Traits>::__parse_one_char_or_coll_elem_RE( | 
|  | 3141 | _ForwardIterator __first, | 
|  | 3142 | _ForwardIterator __last) | 
|  | 3143 | { | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 3144 | _ForwardIterator __temp = __parse_ORD_CHAR(__first, __last); | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 3145 | if (__temp == __first) | 
|  | 3146 | { | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 3147 | __temp = __parse_QUOTED_CHAR(__first, __last); | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 3148 | if (__temp == __first) | 
|  | 3149 | { | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 3150 | if (__temp != __last && *__temp == '.') | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 3151 | { | 
|  | 3152 | __push_match_any(); | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 3153 | ++__temp; | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 3154 | } | 
|  | 3155 | else | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 3156 | __temp = __parse_bracket_expression(__first, __last); | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 3157 | } | 
|  | 3158 | } | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 3159 | __first = __temp; | 
|  | 3160 | return __first; | 
|  | 3161 | } | 
|  | 3162 |  | 
|  | 3163 | template <class _CharT, class _Traits> | 
|  | 3164 | template <class _ForwardIterator> | 
|  | 3165 | _ForwardIterator | 
|  | 3166 | basic_regex<_CharT, _Traits>::__parse_one_char_or_coll_elem_ERE( | 
|  | 3167 | _ForwardIterator __first, | 
|  | 3168 | _ForwardIterator __last) | 
|  | 3169 | { | 
|  | 3170 | _ForwardIterator __temp = __parse_ORD_CHAR_ERE(__first, __last); | 
|  | 3171 | if (__temp == __first) | 
|  | 3172 | { | 
|  | 3173 | __temp = __parse_QUOTED_CHAR_ERE(__first, __last); | 
|  | 3174 | if (__temp == __first) | 
|  | 3175 | { | 
|  | 3176 | if (__temp != __last && *__temp == '.') | 
|  | 3177 | { | 
|  | 3178 | __push_match_any(); | 
|  | 3179 | ++__temp; | 
|  | 3180 | } | 
|  | 3181 | else | 
|  | 3182 | __temp = __parse_bracket_expression(__first, __last); | 
|  | 3183 | } | 
|  | 3184 | } | 
|  | 3185 | __first = __temp; | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 3186 | return __first; | 
|  | 3187 | } | 
|  | 3188 |  | 
|  | 3189 | template <class _CharT, class _Traits> | 
|  | 3190 | template <class _ForwardIterator> | 
|  | 3191 | _ForwardIterator | 
|  | 3192 | basic_regex<_CharT, _Traits>::__parse_Back_open_paren(_ForwardIterator __first, | 
|  | 3193 | _ForwardIterator __last) | 
|  | 3194 | { | 
|  | 3195 | if (__first != __last) | 
|  | 3196 | { | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 3197 | _ForwardIterator __temp = _VSTD::next(__first); | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 3198 | if (__temp != __last) | 
|  | 3199 | { | 
|  | 3200 | if (*__first == '\\' && *__temp == '(') | 
|  | 3201 | __first = ++__temp; | 
|  | 3202 | } | 
|  | 3203 | } | 
|  | 3204 | return __first; | 
|  | 3205 | } | 
|  | 3206 |  | 
|  | 3207 | template <class _CharT, class _Traits> | 
|  | 3208 | template <class _ForwardIterator> | 
|  | 3209 | _ForwardIterator | 
|  | 3210 | basic_regex<_CharT, _Traits>::__parse_Back_close_paren(_ForwardIterator __first, | 
|  | 3211 | _ForwardIterator __last) | 
|  | 3212 | { | 
|  | 3213 | if (__first != __last) | 
|  | 3214 | { | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 3215 | _ForwardIterator __temp = _VSTD::next(__first); | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 3216 | if (__temp != __last) | 
|  | 3217 | { | 
|  | 3218 | if (*__first == '\\' && *__temp == ')') | 
|  | 3219 | __first = ++__temp; | 
|  | 3220 | } | 
|  | 3221 | } | 
|  | 3222 | return __first; | 
|  | 3223 | } | 
|  | 3224 |  | 
|  | 3225 | template <class _CharT, class _Traits> | 
|  | 3226 | template <class _ForwardIterator> | 
|  | 3227 | _ForwardIterator | 
|  | 3228 | basic_regex<_CharT, _Traits>::__parse_Back_open_brace(_ForwardIterator __first, | 
|  | 3229 | _ForwardIterator __last) | 
|  | 3230 | { | 
|  | 3231 | if (__first != __last) | 
|  | 3232 | { | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 3233 | _ForwardIterator __temp = _VSTD::next(__first); | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 3234 | if (__temp != __last) | 
|  | 3235 | { | 
|  | 3236 | if (*__first == '\\' && *__temp == '{') | 
|  | 3237 | __first = ++__temp; | 
|  | 3238 | } | 
|  | 3239 | } | 
|  | 3240 | return __first; | 
|  | 3241 | } | 
|  | 3242 |  | 
|  | 3243 | template <class _CharT, class _Traits> | 
|  | 3244 | template <class _ForwardIterator> | 
|  | 3245 | _ForwardIterator | 
|  | 3246 | basic_regex<_CharT, _Traits>::__parse_Back_close_brace(_ForwardIterator __first, | 
|  | 3247 | _ForwardIterator __last) | 
|  | 3248 | { | 
|  | 3249 | if (__first != __last) | 
|  | 3250 | { | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 3251 | _ForwardIterator __temp = _VSTD::next(__first); | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 3252 | if (__temp != __last) | 
|  | 3253 | { | 
|  | 3254 | if (*__first == '\\' && *__temp == '}') | 
|  | 3255 | __first = ++__temp; | 
|  | 3256 | } | 
|  | 3257 | } | 
|  | 3258 | return __first; | 
|  | 3259 | } | 
|  | 3260 |  | 
|  | 3261 | template <class _CharT, class _Traits> | 
|  | 3262 | template <class _ForwardIterator> | 
|  | 3263 | _ForwardIterator | 
|  | 3264 | basic_regex<_CharT, _Traits>::__parse_BACKREF(_ForwardIterator __first, | 
|  | 3265 | _ForwardIterator __last) | 
|  | 3266 | { | 
|  | 3267 | if (__first != __last) | 
|  | 3268 | { | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 3269 | _ForwardIterator __temp = _VSTD::next(__first); | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 3270 | if (__temp != __last) | 
|  | 3271 | { | 
|  | 3272 | if (*__first == '\\' && '1' <= *__temp && *__temp <= '9') | 
|  | 3273 | { | 
|  | 3274 | __push_back_ref(*__temp - '0'); | 
|  | 3275 | __first = ++__temp; | 
|  | 3276 | } | 
|  | 3277 | } | 
|  | 3278 | } | 
|  | 3279 | return __first; | 
|  | 3280 | } | 
|  | 3281 |  | 
|  | 3282 | template <class _CharT, class _Traits> | 
|  | 3283 | template <class _ForwardIterator> | 
|  | 3284 | _ForwardIterator | 
|  | 3285 | basic_regex<_CharT, _Traits>::__parse_ORD_CHAR(_ForwardIterator __first, | 
|  | 3286 | _ForwardIterator __last) | 
|  | 3287 | { | 
|  | 3288 | if (__first != __last) | 
|  | 3289 | { | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 3290 | _ForwardIterator __temp = _VSTD::next(__first); | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 3291 | if (__temp == __last && *__first == '$') | 
|  | 3292 | return __first; | 
|  | 3293 | // Not called inside a bracket | 
|  | 3294 | if (*__first == '.' || *__first == '\\' || *__first == '[') | 
|  | 3295 | return __first; | 
| Howard Hinnant | 0de86b6 | 2010-06-25 20:56:08 | [diff] [blame] | 3296 | __push_char(*__first); | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 3297 | ++__first; | 
|  | 3298 | } | 
|  | 3299 | return __first; | 
|  | 3300 | } | 
|  | 3301 |  | 
|  | 3302 | template <class _CharT, class _Traits> | 
|  | 3303 | template <class _ForwardIterator> | 
|  | 3304 | _ForwardIterator | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 3305 | basic_regex<_CharT, _Traits>::__parse_ORD_CHAR_ERE(_ForwardIterator __first, | 
|  | 3306 | _ForwardIterator __last) | 
|  | 3307 | { | 
|  | 3308 | if (__first != __last) | 
|  | 3309 | { | 
|  | 3310 | switch (*__first) | 
|  | 3311 | { | 
|  | 3312 | case '^': | 
|  | 3313 | case '.': | 
|  | 3314 | case '[': | 
|  | 3315 | case '$': | 
|  | 3316 | case '(': | 
|  | 3317 | case '|': | 
|  | 3318 | case '*': | 
|  | 3319 | case '+': | 
|  | 3320 | case '?': | 
|  | 3321 | case '{': | 
|  | 3322 | case '\\': | 
|  | 3323 | break; | 
|  | 3324 | case ')': | 
|  | 3325 | if (__open_count_ == 0) | 
|  | 3326 | { | 
|  | 3327 | __push_char(*__first); | 
|  | 3328 | ++__first; | 
|  | 3329 | } | 
|  | 3330 | break; | 
|  | 3331 | default: | 
|  | 3332 | __push_char(*__first); | 
|  | 3333 | ++__first; | 
|  | 3334 | break; | 
|  | 3335 | } | 
|  | 3336 | } | 
|  | 3337 | return __first; | 
|  | 3338 | } | 
|  | 3339 |  | 
|  | 3340 | template <class _CharT, class _Traits> | 
|  | 3341 | template <class _ForwardIterator> | 
|  | 3342 | _ForwardIterator | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 3343 | basic_regex<_CharT, _Traits>::__parse_QUOTED_CHAR(_ForwardIterator __first, | 
|  | 3344 | _ForwardIterator __last) | 
|  | 3345 | { | 
|  | 3346 | if (__first != __last) | 
|  | 3347 | { | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 3348 | _ForwardIterator __temp = _VSTD::next(__first); | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 3349 | if (__temp != __last) | 
|  | 3350 | { | 
|  | 3351 | if (*__first == '\\') | 
|  | 3352 | { | 
|  | 3353 | switch (*__temp) | 
|  | 3354 | { | 
|  | 3355 | case '^': | 
|  | 3356 | case '.': | 
|  | 3357 | case '*': | 
|  | 3358 | case '[': | 
|  | 3359 | case '$': | 
|  | 3360 | case '\\': | 
| Howard Hinnant | 0de86b6 | 2010-06-25 20:56:08 | [diff] [blame] | 3361 | __push_char(*__temp); | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 3362 | __first = ++__temp; | 
|  | 3363 | break; | 
|  | 3364 | } | 
|  | 3365 | } | 
|  | 3366 | } | 
|  | 3367 | } | 
|  | 3368 | return __first; | 
|  | 3369 | } | 
|  | 3370 |  | 
|  | 3371 | template <class _CharT, class _Traits> | 
|  | 3372 | template <class _ForwardIterator> | 
|  | 3373 | _ForwardIterator | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 3374 | basic_regex<_CharT, _Traits>::__parse_QUOTED_CHAR_ERE(_ForwardIterator __first, | 
|  | 3375 | _ForwardIterator __last) | 
|  | 3376 | { | 
|  | 3377 | if (__first != __last) | 
|  | 3378 | { | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 3379 | _ForwardIterator __temp = _VSTD::next(__first); | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 3380 | if (__temp != __last) | 
|  | 3381 | { | 
|  | 3382 | if (*__first == '\\') | 
|  | 3383 | { | 
|  | 3384 | switch (*__temp) | 
|  | 3385 | { | 
|  | 3386 | case '^': | 
|  | 3387 | case '.': | 
|  | 3388 | case '*': | 
|  | 3389 | case '[': | 
|  | 3390 | case '$': | 
|  | 3391 | case '\\': | 
|  | 3392 | case '(': | 
|  | 3393 | case ')': | 
|  | 3394 | case '|': | 
|  | 3395 | case '+': | 
|  | 3396 | case '?': | 
|  | 3397 | case '{': | 
|  | 3398 | __push_char(*__temp); | 
|  | 3399 | __first = ++__temp; | 
|  | 3400 | break; | 
| Howard Hinnant | 15476f3 | 2010-07-28 17:35:27 | [diff] [blame] | 3401 | default: | 
|  | 3402 | if ((__flags_ & 0x1F0) == awk) | 
|  | 3403 | __first = __parse_awk_escape(++__first, __last); | 
|  | 3404 | break; | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 3405 | } | 
|  | 3406 | } | 
|  | 3407 | } | 
|  | 3408 | } | 
|  | 3409 | return __first; | 
|  | 3410 | } | 
|  | 3411 |  | 
|  | 3412 | template <class _CharT, class _Traits> | 
|  | 3413 | template <class _ForwardIterator> | 
|  | 3414 | _ForwardIterator | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 3415 | basic_regex<_CharT, _Traits>::__parse_RE_dupl_symbol(_ForwardIterator __first, | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 3416 | _ForwardIterator __last, | 
| Howard Hinnant | e77aa5e | 2010-07-08 17:43:58 | [diff] [blame] | 3417 | __owns_one_state<_CharT>* __s, | 
|  | 3418 | unsigned __mexp_begin, | 
|  | 3419 | unsigned __mexp_end) | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 3420 | { | 
|  | 3421 | if (__first != __last) | 
|  | 3422 | { | 
| Howard Hinnant | 0de86b6 | 2010-06-25 20:56:08 | [diff] [blame] | 3423 | if (*__first == '*') | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 3424 | { | 
| Howard Hinnant | e77aa5e | 2010-07-08 17:43:58 | [diff] [blame] | 3425 | __push_greedy_inf_repeat(0, __s, __mexp_begin, __mexp_end); | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 3426 | ++__first; | 
|  | 3427 | } | 
|  | 3428 | else | 
|  | 3429 | { | 
|  | 3430 | _ForwardIterator __temp = __parse_Back_open_brace(__first, __last); | 
|  | 3431 | if (__temp != __first) | 
|  | 3432 | { | 
|  | 3433 | int __min = 0; | 
|  | 3434 | __first = __temp; | 
|  | 3435 | __temp = __parse_DUP_COUNT(__first, __last, __min); | 
| Howard Hinnant | d444470 | 2010-08-11 17:04:31 | [diff] [blame] | 3436 | #ifndef _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 3437 | if (__temp == __first) | 
|  | 3438 | throw regex_error(regex_constants::error_badbrace); | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 | [diff] [blame] | 3439 | #endif // _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 3440 | __first = __temp; | 
| Howard Hinnant | d444470 | 2010-08-11 17:04:31 | [diff] [blame] | 3441 | #ifndef _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 3442 | if (__first == __last) | 
|  | 3443 | throw regex_error(regex_constants::error_brace); | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 | [diff] [blame] | 3444 | #endif // _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 3445 | if (*__first != ',') | 
|  | 3446 | { | 
|  | 3447 | __temp = __parse_Back_close_brace(__first, __last); | 
| Howard Hinnant | d444470 | 2010-08-11 17:04:31 | [diff] [blame] | 3448 | #ifndef _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 3449 | if (__temp == __first) | 
|  | 3450 | throw regex_error(regex_constants::error_brace); | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 | [diff] [blame] | 3451 | #endif // _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | cba352d | 2010-07-12 18:16:05 | [diff] [blame] | 3452 | __push_loop(__min, __min, __s, __mexp_begin, __mexp_end, | 
|  | 3453 | true); | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 3454 | __first = __temp; | 
|  | 3455 | } | 
|  | 3456 | else | 
|  | 3457 | { | 
|  | 3458 | ++__first; // consume ',' | 
|  | 3459 | int __max = -1; | 
|  | 3460 | __first = __parse_DUP_COUNT(__first, __last, __max); | 
|  | 3461 | __temp = __parse_Back_close_brace(__first, __last); | 
| Howard Hinnant | d444470 | 2010-08-11 17:04:31 | [diff] [blame] | 3462 | #ifndef _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 3463 | if (__temp == __first) | 
|  | 3464 | throw regex_error(regex_constants::error_brace); | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 | [diff] [blame] | 3465 | #endif // _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 3466 | if (__max == -1) | 
| Howard Hinnant | aa69808 | 2010-07-16 19:08:36 | [diff] [blame] | 3467 | __push_greedy_inf_repeat(__min, __s, __mexp_begin, __mexp_end); | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 3468 | else | 
|  | 3469 | { | 
| Howard Hinnant | d444470 | 2010-08-11 17:04:31 | [diff] [blame] | 3470 | #ifndef _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 3471 | if (__max < __min) | 
|  | 3472 | throw regex_error(regex_constants::error_badbrace); | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 | [diff] [blame] | 3473 | #endif // _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | cba352d | 2010-07-12 18:16:05 | [diff] [blame] | 3474 | __push_loop(__min, __max, __s, __mexp_begin, __mexp_end, | 
|  | 3475 | true); | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 3476 | } | 
|  | 3477 | __first = __temp; | 
|  | 3478 | } | 
|  | 3479 | } | 
|  | 3480 | } | 
|  | 3481 | } | 
|  | 3482 | return __first; | 
|  | 3483 | } | 
|  | 3484 |  | 
| Howard Hinnant | 0de86b6 | 2010-06-25 20:56:08 | [diff] [blame] | 3485 | template <class _CharT, class _Traits> | 
|  | 3486 | template <class _ForwardIterator> | 
|  | 3487 | _ForwardIterator | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 3488 | basic_regex<_CharT, _Traits>::__parse_ERE_dupl_symbol(_ForwardIterator __first, | 
| Howard Hinnant | aa69808 | 2010-07-16 19:08:36 | [diff] [blame] | 3489 | _ForwardIterator __last, | 
|  | 3490 | __owns_one_state<_CharT>* __s, | 
|  | 3491 | unsigned __mexp_begin, | 
|  | 3492 | unsigned __mexp_end) | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 3493 | { | 
|  | 3494 | if (__first != __last) | 
|  | 3495 | { | 
| Howard Hinnant | a0d045b | 2010-07-29 00:36:00 | [diff] [blame] | 3496 | unsigned __grammar = __flags_ & 0x1F0; | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 3497 | switch (*__first) | 
|  | 3498 | { | 
|  | 3499 | case '*': | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 3500 | ++__first; | 
| Howard Hinnant | a0d045b | 2010-07-29 00:36:00 | [diff] [blame] | 3501 | if (__grammar == ECMAScript && __first != __last && *__first == '?') | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 3502 | { | 
|  | 3503 | ++__first; | 
|  | 3504 | __push_nongreedy_inf_repeat(0, __s, __mexp_begin, __mexp_end); | 
|  | 3505 | } | 
|  | 3506 | else | 
|  | 3507 | __push_greedy_inf_repeat(0, __s, __mexp_begin, __mexp_end); | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 3508 | break; | 
|  | 3509 | case '+': | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 3510 | ++__first; | 
| Howard Hinnant | a0d045b | 2010-07-29 00:36:00 | [diff] [blame] | 3511 | if (__grammar == ECMAScript && __first != __last && *__first == '?') | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 3512 | { | 
|  | 3513 | ++__first; | 
|  | 3514 | __push_nongreedy_inf_repeat(1, __s, __mexp_begin, __mexp_end); | 
|  | 3515 | } | 
|  | 3516 | else | 
|  | 3517 | __push_greedy_inf_repeat(1, __s, __mexp_begin, __mexp_end); | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 3518 | break; | 
|  | 3519 | case '?': | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 3520 | ++__first; | 
| Howard Hinnant | a0d045b | 2010-07-29 00:36:00 | [diff] [blame] | 3521 | if (__grammar == ECMAScript && __first != __last && *__first == '?') | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 3522 | { | 
|  | 3523 | ++__first; | 
|  | 3524 | __push_loop(0, 1, __s, __mexp_begin, __mexp_end, false); | 
|  | 3525 | } | 
|  | 3526 | else | 
|  | 3527 | __push_loop(0, 1, __s, __mexp_begin, __mexp_end); | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 3528 | break; | 
|  | 3529 | case '{': | 
|  | 3530 | { | 
|  | 3531 | int __min; | 
| Howard Hinnant | aa69808 | 2010-07-16 19:08:36 | [diff] [blame] | 3532 | _ForwardIterator __temp = __parse_DUP_COUNT(++__first, __last, __min); | 
| Howard Hinnant | d444470 | 2010-08-11 17:04:31 | [diff] [blame] | 3533 | #ifndef _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 3534 | if (__temp == __first) | 
|  | 3535 | throw regex_error(regex_constants::error_badbrace); | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 | [diff] [blame] | 3536 | #endif // _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 3537 | __first = __temp; | 
| Howard Hinnant | d444470 | 2010-08-11 17:04:31 | [diff] [blame] | 3538 | #ifndef _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 3539 | if (__first == __last) | 
|  | 3540 | throw regex_error(regex_constants::error_brace); | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 | [diff] [blame] | 3541 | #endif // _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 3542 | switch (*__first) | 
|  | 3543 | { | 
|  | 3544 | case '}': | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 3545 | ++__first; | 
| Howard Hinnant | a0d045b | 2010-07-29 00:36:00 | [diff] [blame] | 3546 | if (__grammar == ECMAScript && __first != __last && *__first == '?') | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 3547 | { | 
|  | 3548 | ++__first; | 
|  | 3549 | __push_loop(__min, __min, __s, __mexp_begin, __mexp_end, false); | 
|  | 3550 | } | 
|  | 3551 | else | 
|  | 3552 | __push_loop(__min, __min, __s, __mexp_begin, __mexp_end); | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 3553 | break; | 
|  | 3554 | case ',': | 
| Howard Hinnant | d444470 | 2010-08-11 17:04:31 | [diff] [blame] | 3555 | ++__first; | 
|  | 3556 | #ifndef _LIBCPP_NO_EXCEPTIONS | 
|  | 3557 | if (__first == __last) | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 3558 | throw regex_error(regex_constants::error_badbrace); | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 | [diff] [blame] | 3559 | #endif // _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 3560 | if (*__first == '}') | 
|  | 3561 | { | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 3562 | ++__first; | 
| Howard Hinnant | a0d045b | 2010-07-29 00:36:00 | [diff] [blame] | 3563 | if (__grammar == ECMAScript && __first != __last && *__first == '?') | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 3564 | { | 
|  | 3565 | ++__first; | 
|  | 3566 | __push_nongreedy_inf_repeat(__min, __s, __mexp_begin, __mexp_end); | 
|  | 3567 | } | 
|  | 3568 | else | 
|  | 3569 | __push_greedy_inf_repeat(__min, __s, __mexp_begin, __mexp_end); | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 3570 | } | 
|  | 3571 | else | 
|  | 3572 | { | 
| Howard Hinnant | aa69808 | 2010-07-16 19:08:36 | [diff] [blame] | 3573 | int __max = -1; | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 3574 | __temp = __parse_DUP_COUNT(__first, __last, __max); | 
| Howard Hinnant | d444470 | 2010-08-11 17:04:31 | [diff] [blame] | 3575 | #ifndef _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 3576 | if (__temp == __first) | 
|  | 3577 | throw regex_error(regex_constants::error_brace); | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 | [diff] [blame] | 3578 | #endif // _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 3579 | __first = __temp; | 
| Howard Hinnant | d444470 | 2010-08-11 17:04:31 | [diff] [blame] | 3580 | #ifndef _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 3581 | if (__first == __last || *__first != '}') | 
|  | 3582 | throw regex_error(regex_constants::error_brace); | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 | [diff] [blame] | 3583 | #endif // _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 3584 | ++__first; | 
| Howard Hinnant | d444470 | 2010-08-11 17:04:31 | [diff] [blame] | 3585 | #ifndef _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 3586 | if (__max < __min) | 
|  | 3587 | throw regex_error(regex_constants::error_badbrace); | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 | [diff] [blame] | 3588 | #endif // _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | a0d045b | 2010-07-29 00:36:00 | [diff] [blame] | 3589 | if (__grammar == ECMAScript && __first != __last && *__first == '?') | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 3590 | { | 
|  | 3591 | ++__first; | 
|  | 3592 | __push_loop(__min, __max, __s, __mexp_begin, __mexp_end, false); | 
|  | 3593 | } | 
|  | 3594 | else | 
|  | 3595 | __push_loop(__min, __max, __s, __mexp_begin, __mexp_end); | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 3596 | } | 
| Howard Hinnant | aa69808 | 2010-07-16 19:08:36 | [diff] [blame] | 3597 | break; | 
| Howard Hinnant | d444470 | 2010-08-11 17:04:31 | [diff] [blame] | 3598 | #ifndef _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 3599 | default: | 
|  | 3600 | throw regex_error(regex_constants::error_badbrace); | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 | [diff] [blame] | 3601 | #endif // _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 3602 | } | 
|  | 3603 | } | 
|  | 3604 | break; | 
|  | 3605 | } | 
|  | 3606 | } | 
|  | 3607 | return __first; | 
|  | 3608 | } | 
|  | 3609 |  | 
|  | 3610 | template <class _CharT, class _Traits> | 
|  | 3611 | template <class _ForwardIterator> | 
|  | 3612 | _ForwardIterator | 
| Howard Hinnant | 0de86b6 | 2010-06-25 20:56:08 | [diff] [blame] | 3613 | basic_regex<_CharT, _Traits>::__parse_bracket_expression(_ForwardIterator __first, | 
|  | 3614 | _ForwardIterator __last) | 
|  | 3615 | { | 
|  | 3616 | if (__first != __last && *__first == '[') | 
|  | 3617 | { | 
| Howard Hinnant | d444470 | 2010-08-11 17:04:31 | [diff] [blame] | 3618 | ++__first; | 
|  | 3619 | #ifndef _LIBCPP_NO_EXCEPTIONS | 
|  | 3620 | if (__first == __last) | 
| Howard Hinnant | 0de86b6 | 2010-06-25 20:56:08 | [diff] [blame] | 3621 | throw regex_error(regex_constants::error_brack); | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 | [diff] [blame] | 3622 | #endif // _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | 173968a | 2010-07-13 21:48:06 | [diff] [blame] | 3623 | bool __negate = false; | 
| Howard Hinnant | 0de86b6 | 2010-06-25 20:56:08 | [diff] [blame] | 3624 | if (*__first == '^') | 
|  | 3625 | { | 
|  | 3626 | ++__first; | 
| Howard Hinnant | 173968a | 2010-07-13 21:48:06 | [diff] [blame] | 3627 | __negate = true; | 
| Howard Hinnant | 0de86b6 | 2010-06-25 20:56:08 | [diff] [blame] | 3628 | } | 
| Howard Hinnant | 173968a | 2010-07-13 21:48:06 | [diff] [blame] | 3629 | __bracket_expression<_CharT, _Traits>* __ml = __start_matching_list(__negate); | 
|  | 3630 | // __ml owned by *this | 
| Howard Hinnant | d444470 | 2010-08-11 17:04:31 | [diff] [blame] | 3631 | #ifndef _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | 0de86b6 | 2010-06-25 20:56:08 | [diff] [blame] | 3632 | if (__first == __last) | 
|  | 3633 | throw regex_error(regex_constants::error_brack); | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 | [diff] [blame] | 3634 | #endif // _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | 15476f3 | 2010-07-28 17:35:27 | [diff] [blame] | 3635 | if ((__flags_ & 0x1F0) != ECMAScript && *__first == ']') | 
| Howard Hinnant | 0de86b6 | 2010-06-25 20:56:08 | [diff] [blame] | 3636 | { | 
| Howard Hinnant | 173968a | 2010-07-13 21:48:06 | [diff] [blame] | 3637 | __ml->__add_char(']'); | 
| Howard Hinnant | 0de86b6 | 2010-06-25 20:56:08 | [diff] [blame] | 3638 | ++__first; | 
|  | 3639 | } | 
| Howard Hinnant | 173968a | 2010-07-13 21:48:06 | [diff] [blame] | 3640 | __first = __parse_follow_list(__first, __last, __ml); | 
| Howard Hinnant | d444470 | 2010-08-11 17:04:31 | [diff] [blame] | 3641 | #ifndef _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | 0de86b6 | 2010-06-25 20:56:08 | [diff] [blame] | 3642 | if (__first == __last) | 
|  | 3643 | throw regex_error(regex_constants::error_brack); | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 | [diff] [blame] | 3644 | #endif // _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | 0de86b6 | 2010-06-25 20:56:08 | [diff] [blame] | 3645 | if (*__first == '-') | 
|  | 3646 | { | 
| Howard Hinnant | 173968a | 2010-07-13 21:48:06 | [diff] [blame] | 3647 | __ml->__add_char('-'); | 
| Howard Hinnant | 0de86b6 | 2010-06-25 20:56:08 | [diff] [blame] | 3648 | ++__first; | 
|  | 3649 | } | 
| Howard Hinnant | d444470 | 2010-08-11 17:04:31 | [diff] [blame] | 3650 | #ifndef _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | 0de86b6 | 2010-06-25 20:56:08 | [diff] [blame] | 3651 | if (__first == __last || *__first != ']') | 
|  | 3652 | throw regex_error(regex_constants::error_brack); | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 | [diff] [blame] | 3653 | #endif // _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | 0de86b6 | 2010-06-25 20:56:08 | [diff] [blame] | 3654 | ++__first; | 
|  | 3655 | } | 
|  | 3656 | return __first; | 
|  | 3657 | } | 
|  | 3658 |  | 
|  | 3659 | template <class _CharT, class _Traits> | 
|  | 3660 | template <class _ForwardIterator> | 
|  | 3661 | _ForwardIterator | 
|  | 3662 | basic_regex<_CharT, _Traits>::__parse_follow_list(_ForwardIterator __first, | 
| Howard Hinnant | 173968a | 2010-07-13 21:48:06 | [diff] [blame] | 3663 | _ForwardIterator __last, | 
|  | 3664 | __bracket_expression<_CharT, _Traits>* __ml) | 
| Howard Hinnant | 0de86b6 | 2010-06-25 20:56:08 | [diff] [blame] | 3665 | { | 
|  | 3666 | if (__first != __last) | 
|  | 3667 | { | 
|  | 3668 | while (true) | 
|  | 3669 | { | 
| Howard Hinnant | 173968a | 2010-07-13 21:48:06 | [diff] [blame] | 3670 | _ForwardIterator __temp = __parse_expression_term(__first, __last, | 
|  | 3671 | __ml); | 
| Howard Hinnant | 0de86b6 | 2010-06-25 20:56:08 | [diff] [blame] | 3672 | if (__temp == __first) | 
|  | 3673 | break; | 
|  | 3674 | __first = __temp; | 
|  | 3675 | } | 
|  | 3676 | } | 
|  | 3677 | return __first; | 
|  | 3678 | } | 
|  | 3679 |  | 
|  | 3680 | template <class _CharT, class _Traits> | 
|  | 3681 | template <class _ForwardIterator> | 
|  | 3682 | _ForwardIterator | 
|  | 3683 | basic_regex<_CharT, _Traits>::__parse_expression_term(_ForwardIterator __first, | 
| Howard Hinnant | 173968a | 2010-07-13 21:48:06 | [diff] [blame] | 3684 | _ForwardIterator __last, | 
|  | 3685 | __bracket_expression<_CharT, _Traits>* __ml) | 
| Howard Hinnant | 0de86b6 | 2010-06-25 20:56:08 | [diff] [blame] | 3686 | { | 
|  | 3687 | if (__first != __last && *__first != ']') | 
|  | 3688 | { | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 3689 | _ForwardIterator __temp = _VSTD::next(__first); | 
| Howard Hinnant | 173968a | 2010-07-13 21:48:06 | [diff] [blame] | 3690 | basic_string<_CharT> __start_range; | 
| Howard Hinnant | 0de86b6 | 2010-06-25 20:56:08 | [diff] [blame] | 3691 | if (__temp != __last && *__first == '[') | 
|  | 3692 | { | 
|  | 3693 | if (*__temp == '=') | 
| Howard Hinnant | 173968a | 2010-07-13 21:48:06 | [diff] [blame] | 3694 | return __parse_equivalence_class(++__temp, __last, __ml); | 
| Howard Hinnant | 0de86b6 | 2010-06-25 20:56:08 | [diff] [blame] | 3695 | else if (*__temp == ':') | 
| Howard Hinnant | 173968a | 2010-07-13 21:48:06 | [diff] [blame] | 3696 | return __parse_character_class(++__temp, __last, __ml); | 
| Howard Hinnant | 0de86b6 | 2010-06-25 20:56:08 | [diff] [blame] | 3697 | else if (*__temp == '.') | 
| Howard Hinnant | 173968a | 2010-07-13 21:48:06 | [diff] [blame] | 3698 | __first = __parse_collating_symbol(++__temp, __last, __start_range); | 
| Howard Hinnant | 0de86b6 | 2010-06-25 20:56:08 | [diff] [blame] | 3699 | } | 
| Howard Hinnant | 15476f3 | 2010-07-28 17:35:27 | [diff] [blame] | 3700 | unsigned __grammar = __flags_ & 0x1F0; | 
|  | 3701 | if (__start_range.empty()) | 
| Howard Hinnant | 0de86b6 | 2010-06-25 20:56:08 | [diff] [blame] | 3702 | { | 
| Howard Hinnant | 15476f3 | 2010-07-28 17:35:27 | [diff] [blame] | 3703 | if ((__grammar == ECMAScript || __grammar == awk) && *__first == '\\') | 
|  | 3704 | { | 
|  | 3705 | if (__grammar == ECMAScript) | 
|  | 3706 | __first = __parse_class_escape(++__first, __last, __start_range, __ml); | 
|  | 3707 | else | 
|  | 3708 | __first = __parse_awk_escape(++__first, __last, &__start_range); | 
|  | 3709 | } | 
|  | 3710 | else | 
|  | 3711 | { | 
|  | 3712 | __start_range = *__first; | 
|  | 3713 | ++__first; | 
|  | 3714 | } | 
| Howard Hinnant | 0de86b6 | 2010-06-25 20:56:08 | [diff] [blame] | 3715 | } | 
|  | 3716 | if (__first != __last && *__first != ']') | 
|  | 3717 | { | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 3718 | __temp = _VSTD::next(__first); | 
| Howard Hinnant | 0de86b6 | 2010-06-25 20:56:08 | [diff] [blame] | 3719 | if (__temp != __last && *__first == '-' && *__temp != ']') | 
|  | 3720 | { | 
|  | 3721 | // parse a range | 
| Howard Hinnant | 173968a | 2010-07-13 21:48:06 | [diff] [blame] | 3722 | basic_string<_CharT> __end_range; | 
| Howard Hinnant | 0de86b6 | 2010-06-25 20:56:08 | [diff] [blame] | 3723 | __first = __temp; | 
|  | 3724 | ++__temp; | 
|  | 3725 | if (__temp != __last && *__first == '[' && *__temp == '.') | 
| Howard Hinnant | 173968a | 2010-07-13 21:48:06 | [diff] [blame] | 3726 | __first = __parse_collating_symbol(++__temp, __last, __end_range); | 
| Howard Hinnant | 0de86b6 | 2010-06-25 20:56:08 | [diff] [blame] | 3727 | else | 
|  | 3728 | { | 
| Howard Hinnant | 15476f3 | 2010-07-28 17:35:27 | [diff] [blame] | 3729 | if ((__grammar == ECMAScript || __grammar == awk) && *__first == '\\') | 
|  | 3730 | { | 
|  | 3731 | if (__grammar == ECMAScript) | 
|  | 3732 | __first = __parse_class_escape(++__first, __last, | 
|  | 3733 | __end_range, __ml); | 
|  | 3734 | else | 
|  | 3735 | __first = __parse_awk_escape(++__first, __last, | 
|  | 3736 | &__end_range); | 
|  | 3737 | } | 
|  | 3738 | else | 
|  | 3739 | { | 
|  | 3740 | __end_range = *__first; | 
|  | 3741 | ++__first; | 
|  | 3742 | } | 
| Howard Hinnant | 0de86b6 | 2010-06-25 20:56:08 | [diff] [blame] | 3743 | } | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 3744 | __ml->__add_range(_VSTD::move(__start_range), _VSTD::move(__end_range)); | 
| Howard Hinnant | 0de86b6 | 2010-06-25 20:56:08 | [diff] [blame] | 3745 | } | 
| Howard Hinnant | 173968a | 2010-07-13 21:48:06 | [diff] [blame] | 3746 | else | 
|  | 3747 | { | 
|  | 3748 | if (__start_range.size() == 1) | 
|  | 3749 | __ml->__add_char(__start_range[0]); | 
|  | 3750 | else | 
|  | 3751 | __ml->__add_digraph(__start_range[0], __start_range[1]); | 
|  | 3752 | } | 
|  | 3753 | } | 
|  | 3754 | else | 
|  | 3755 | { | 
|  | 3756 | if (__start_range.size() == 1) | 
|  | 3757 | __ml->__add_char(__start_range[0]); | 
|  | 3758 | else | 
|  | 3759 | __ml->__add_digraph(__start_range[0], __start_range[1]); | 
| Howard Hinnant | 0de86b6 | 2010-06-25 20:56:08 | [diff] [blame] | 3760 | } | 
|  | 3761 | } | 
|  | 3762 | return __first; | 
|  | 3763 | } | 
|  | 3764 |  | 
|  | 3765 | template <class _CharT, class _Traits> | 
|  | 3766 | template <class _ForwardIterator> | 
|  | 3767 | _ForwardIterator | 
| Howard Hinnant | 15476f3 | 2010-07-28 17:35:27 | [diff] [blame] | 3768 | basic_regex<_CharT, _Traits>::__parse_class_escape(_ForwardIterator __first, | 
|  | 3769 | _ForwardIterator __last, | 
|  | 3770 | basic_string<_CharT>& __str, | 
|  | 3771 | __bracket_expression<_CharT, _Traits>* __ml) | 
|  | 3772 | { | 
| Howard Hinnant | d444470 | 2010-08-11 17:04:31 | [diff] [blame] | 3773 | #ifndef _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | 15476f3 | 2010-07-28 17:35:27 | [diff] [blame] | 3774 | if (__first == __last) | 
|  | 3775 | throw regex_error(regex_constants::error_escape); | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 | [diff] [blame] | 3776 | #endif // _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | 15476f3 | 2010-07-28 17:35:27 | [diff] [blame] | 3777 | switch (*__first) | 
|  | 3778 | { | 
|  | 3779 | case 0: | 
|  | 3780 | __str = *__first; | 
|  | 3781 | return ++__first; | 
|  | 3782 | case 'b': | 
|  | 3783 | __str = _CharT(8); | 
|  | 3784 | return ++__first; | 
|  | 3785 | case 'd': | 
|  | 3786 | __ml->__add_class(ctype_base::digit); | 
|  | 3787 | return ++__first; | 
|  | 3788 | case 'D': | 
|  | 3789 | __ml->__add_neg_class(ctype_base::digit); | 
|  | 3790 | return ++__first; | 
|  | 3791 | case 's': | 
|  | 3792 | __ml->__add_class(ctype_base::space); | 
|  | 3793 | return ++__first; | 
|  | 3794 | case 'S': | 
|  | 3795 | __ml->__add_neg_class(ctype_base::space); | 
|  | 3796 | return ++__first; | 
|  | 3797 | case 'w': | 
|  | 3798 | __ml->__add_class(ctype_base::alnum); | 
|  | 3799 | __ml->__add_char('_'); | 
|  | 3800 | return ++__first; | 
|  | 3801 | case 'W': | 
|  | 3802 | __ml->__add_neg_class(ctype_base::alnum); | 
|  | 3803 | __ml->__add_neg_char('_'); | 
|  | 3804 | return ++__first; | 
|  | 3805 | } | 
|  | 3806 | __first = __parse_character_escape(__first, __last, &__str); | 
|  | 3807 | return __first; | 
|  | 3808 | } | 
|  | 3809 |  | 
|  | 3810 | template <class _CharT, class _Traits> | 
|  | 3811 | template <class _ForwardIterator> | 
|  | 3812 | _ForwardIterator | 
|  | 3813 | basic_regex<_CharT, _Traits>::__parse_awk_escape(_ForwardIterator __first, | 
|  | 3814 | _ForwardIterator __last, | 
|  | 3815 | basic_string<_CharT>* __str) | 
|  | 3816 | { | 
| Howard Hinnant | d444470 | 2010-08-11 17:04:31 | [diff] [blame] | 3817 | #ifndef _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | 15476f3 | 2010-07-28 17:35:27 | [diff] [blame] | 3818 | if (__first == __last) | 
|  | 3819 | throw regex_error(regex_constants::error_escape); | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 | [diff] [blame] | 3820 | #endif // _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | 15476f3 | 2010-07-28 17:35:27 | [diff] [blame] | 3821 | switch (*__first) | 
|  | 3822 | { | 
|  | 3823 | case '\\': | 
|  | 3824 | case '"': | 
|  | 3825 | case '/': | 
|  | 3826 | if (__str) | 
|  | 3827 | *__str = *__first; | 
|  | 3828 | else | 
|  | 3829 | __push_char(*__first); | 
|  | 3830 | return ++__first; | 
|  | 3831 | case 'a': | 
|  | 3832 | if (__str) | 
|  | 3833 | *__str = _CharT(7); | 
|  | 3834 | else | 
|  | 3835 | __push_char(_CharT(7)); | 
|  | 3836 | return ++__first; | 
|  | 3837 | case 'b': | 
|  | 3838 | if (__str) | 
|  | 3839 | *__str = _CharT(8); | 
|  | 3840 | else | 
|  | 3841 | __push_char(_CharT(8)); | 
|  | 3842 | return ++__first; | 
|  | 3843 | case 'f': | 
|  | 3844 | if (__str) | 
|  | 3845 | *__str = _CharT(0xC); | 
|  | 3846 | else | 
|  | 3847 | __push_char(_CharT(0xC)); | 
|  | 3848 | return ++__first; | 
|  | 3849 | case 'n': | 
|  | 3850 | if (__str) | 
|  | 3851 | *__str = _CharT(0xA); | 
|  | 3852 | else | 
|  | 3853 | __push_char(_CharT(0xA)); | 
|  | 3854 | return ++__first; | 
|  | 3855 | case 'r': | 
|  | 3856 | if (__str) | 
|  | 3857 | *__str = _CharT(0xD); | 
|  | 3858 | else | 
|  | 3859 | __push_char(_CharT(0xD)); | 
|  | 3860 | return ++__first; | 
|  | 3861 | case 't': | 
|  | 3862 | if (__str) | 
|  | 3863 | *__str = _CharT(0x9); | 
|  | 3864 | else | 
|  | 3865 | __push_char(_CharT(0x9)); | 
|  | 3866 | return ++__first; | 
|  | 3867 | case 'v': | 
|  | 3868 | if (__str) | 
|  | 3869 | *__str = _CharT(0xB); | 
|  | 3870 | else | 
|  | 3871 | __push_char(_CharT(0xB)); | 
|  | 3872 | return ++__first; | 
|  | 3873 | } | 
|  | 3874 | if ('0' <= *__first && *__first <= '7') | 
|  | 3875 | { | 
|  | 3876 | unsigned __val = *__first - '0'; | 
|  | 3877 | if (++__first != __last && ('0' <= *__first && *__first <= '7')) | 
|  | 3878 | { | 
|  | 3879 | __val = 8 * __val + *__first - '0'; | 
|  | 3880 | if (++__first != __last && ('0' <= *__first && *__first <= '7')) | 
|  | 3881 | __val = 8 * __val + *__first - '0'; | 
|  | 3882 | } | 
|  | 3883 | if (__str) | 
|  | 3884 | *__str = _CharT(__val); | 
|  | 3885 | else | 
|  | 3886 | __push_char(_CharT(__val)); | 
|  | 3887 | } | 
| Howard Hinnant | d444470 | 2010-08-11 17:04:31 | [diff] [blame] | 3888 | #ifndef _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | 15476f3 | 2010-07-28 17:35:27 | [diff] [blame] | 3889 | else | 
|  | 3890 | throw regex_error(regex_constants::error_escape); | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 | [diff] [blame] | 3891 | #endif // _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | 15476f3 | 2010-07-28 17:35:27 | [diff] [blame] | 3892 | return __first; | 
|  | 3893 | } | 
|  | 3894 |  | 
|  | 3895 | template <class _CharT, class _Traits> | 
|  | 3896 | template <class _ForwardIterator> | 
|  | 3897 | _ForwardIterator | 
| Howard Hinnant | 0de86b6 | 2010-06-25 20:56:08 | [diff] [blame] | 3898 | basic_regex<_CharT, _Traits>::__parse_equivalence_class(_ForwardIterator __first, | 
| Howard Hinnant | 173968a | 2010-07-13 21:48:06 | [diff] [blame] | 3899 | _ForwardIterator __last, | 
|  | 3900 | __bracket_expression<_CharT, _Traits>* __ml) | 
| Howard Hinnant | 0de86b6 | 2010-06-25 20:56:08 | [diff] [blame] | 3901 | { | 
|  | 3902 | // Found [= | 
|  | 3903 | // This means =] must exist | 
|  | 3904 | value_type _Equal_close[2] = {'=', ']'}; | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 3905 | _ForwardIterator __temp = _VSTD::search(__first, __last, _Equal_close, | 
| Howard Hinnant | 0de86b6 | 2010-06-25 20:56:08 | [diff] [blame] | 3906 | _Equal_close+2); | 
| Howard Hinnant | d444470 | 2010-08-11 17:04:31 | [diff] [blame] | 3907 | #ifndef _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | 0de86b6 | 2010-06-25 20:56:08 | [diff] [blame] | 3908 | if (__temp == __last) | 
|  | 3909 | throw regex_error(regex_constants::error_brack); | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 | [diff] [blame] | 3910 | #endif // _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | 0de86b6 | 2010-06-25 20:56:08 | [diff] [blame] | 3911 | // [__first, __temp) contains all text in [= ... =] | 
|  | 3912 | typedef typename _Traits::string_type string_type; | 
|  | 3913 | string_type __collate_name = | 
|  | 3914 | __traits_.lookup_collatename(__first, __temp); | 
| Howard Hinnant | d444470 | 2010-08-11 17:04:31 | [diff] [blame] | 3915 | #ifndef _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | 0de86b6 | 2010-06-25 20:56:08 | [diff] [blame] | 3916 | if (__collate_name.empty()) | 
| Howard Hinnant | 173968a | 2010-07-13 21:48:06 | [diff] [blame] | 3917 | throw regex_error(regex_constants::error_collate); | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 | [diff] [blame] | 3918 | #endif // _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | 0de86b6 | 2010-06-25 20:56:08 | [diff] [blame] | 3919 | string_type __equiv_name = | 
|  | 3920 | __traits_.transform_primary(__collate_name.begin(), | 
|  | 3921 | __collate_name.end()); | 
|  | 3922 | if (!__equiv_name.empty()) | 
| Howard Hinnant | 173968a | 2010-07-13 21:48:06 | [diff] [blame] | 3923 | __ml->__add_equivalence(__equiv_name); | 
| Howard Hinnant | 0de86b6 | 2010-06-25 20:56:08 | [diff] [blame] | 3924 | else | 
| Howard Hinnant | 173968a | 2010-07-13 21:48:06 | [diff] [blame] | 3925 | { | 
|  | 3926 | switch (__collate_name.size()) | 
|  | 3927 | { | 
|  | 3928 | case 1: | 
|  | 3929 | __ml->__add_char(__collate_name[0]); | 
|  | 3930 | break; | 
|  | 3931 | case 2: | 
|  | 3932 | __ml->__add_digraph(__collate_name[0], __collate_name[1]); | 
|  | 3933 | break; | 
| Howard Hinnant | d444470 | 2010-08-11 17:04:31 | [diff] [blame] | 3934 | #ifndef _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | 173968a | 2010-07-13 21:48:06 | [diff] [blame] | 3935 | default: | 
|  | 3936 | throw regex_error(regex_constants::error_collate); | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 | [diff] [blame] | 3937 | #endif // _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | 173968a | 2010-07-13 21:48:06 | [diff] [blame] | 3938 | } | 
|  | 3939 | } | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 3940 | __first = _VSTD::next(__temp, 2); | 
| Howard Hinnant | 0de86b6 | 2010-06-25 20:56:08 | [diff] [blame] | 3941 | return __first; | 
|  | 3942 | } | 
|  | 3943 |  | 
|  | 3944 | template <class _CharT, class _Traits> | 
|  | 3945 | template <class _ForwardIterator> | 
|  | 3946 | _ForwardIterator | 
|  | 3947 | basic_regex<_CharT, _Traits>::__parse_character_class(_ForwardIterator __first, | 
| Howard Hinnant | 173968a | 2010-07-13 21:48:06 | [diff] [blame] | 3948 | _ForwardIterator __last, | 
|  | 3949 | __bracket_expression<_CharT, _Traits>* __ml) | 
| Howard Hinnant | 0de86b6 | 2010-06-25 20:56:08 | [diff] [blame] | 3950 | { | 
|  | 3951 | // Found [: | 
|  | 3952 | // This means :] must exist | 
|  | 3953 | value_type _Colon_close[2] = {':', ']'}; | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 3954 | _ForwardIterator __temp = _VSTD::search(__first, __last, _Colon_close, | 
| Howard Hinnant | 0de86b6 | 2010-06-25 20:56:08 | [diff] [blame] | 3955 | _Colon_close+2); | 
| Howard Hinnant | d444470 | 2010-08-11 17:04:31 | [diff] [blame] | 3956 | #ifndef _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | 0de86b6 | 2010-06-25 20:56:08 | [diff] [blame] | 3957 | if (__temp == __last) | 
|  | 3958 | throw regex_error(regex_constants::error_brack); | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 | [diff] [blame] | 3959 | #endif // _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | 0de86b6 | 2010-06-25 20:56:08 | [diff] [blame] | 3960 | // [__first, __temp) contains all text in [: ... :] | 
|  | 3961 | typedef typename _Traits::char_class_type char_class_type; | 
|  | 3962 | char_class_type __class_type = | 
|  | 3963 | __traits_.lookup_classname(__first, __temp, __flags_ & icase); | 
| Howard Hinnant | d444470 | 2010-08-11 17:04:31 | [diff] [blame] | 3964 | #ifndef _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | 0de86b6 | 2010-06-25 20:56:08 | [diff] [blame] | 3965 | if (__class_type == 0) | 
|  | 3966 | throw regex_error(regex_constants::error_brack); | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 | [diff] [blame] | 3967 | #endif // _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | 173968a | 2010-07-13 21:48:06 | [diff] [blame] | 3968 | __ml->__add_class(__class_type); | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 3969 | __first = _VSTD::next(__temp, 2); | 
| Howard Hinnant | 0de86b6 | 2010-06-25 20:56:08 | [diff] [blame] | 3970 | return __first; | 
|  | 3971 | } | 
|  | 3972 |  | 
|  | 3973 | template <class _CharT, class _Traits> | 
|  | 3974 | template <class _ForwardIterator> | 
|  | 3975 | _ForwardIterator | 
|  | 3976 | basic_regex<_CharT, _Traits>::__parse_collating_symbol(_ForwardIterator __first, | 
| Howard Hinnant | 173968a | 2010-07-13 21:48:06 | [diff] [blame] | 3977 | _ForwardIterator __last, | 
|  | 3978 | basic_string<_CharT>& __col_sym) | 
| Howard Hinnant | 0de86b6 | 2010-06-25 20:56:08 | [diff] [blame] | 3979 | { | 
|  | 3980 | // Found [. | 
|  | 3981 | // This means .] must exist | 
|  | 3982 | value_type _Dot_close[2] = {'.', ']'}; | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 3983 | _ForwardIterator __temp = _VSTD::search(__first, __last, _Dot_close, | 
| Howard Hinnant | 0de86b6 | 2010-06-25 20:56:08 | [diff] [blame] | 3984 | _Dot_close+2); | 
| Howard Hinnant | d444470 | 2010-08-11 17:04:31 | [diff] [blame] | 3985 | #ifndef _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | 0de86b6 | 2010-06-25 20:56:08 | [diff] [blame] | 3986 | if (__temp == __last) | 
|  | 3987 | throw regex_error(regex_constants::error_brack); | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 | [diff] [blame] | 3988 | #endif // _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | 0de86b6 | 2010-06-25 20:56:08 | [diff] [blame] | 3989 | // [__first, __temp) contains all text in [. ... .] | 
|  | 3990 | typedef typename _Traits::string_type string_type; | 
| Howard Hinnant | 173968a | 2010-07-13 21:48:06 | [diff] [blame] | 3991 | __col_sym = __traits_.lookup_collatename(__first, __temp); | 
|  | 3992 | switch (__col_sym.size()) | 
|  | 3993 | { | 
|  | 3994 | case 1: | 
|  | 3995 | case 2: | 
|  | 3996 | break; | 
| Howard Hinnant | d444470 | 2010-08-11 17:04:31 | [diff] [blame] | 3997 | #ifndef _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | 173968a | 2010-07-13 21:48:06 | [diff] [blame] | 3998 | default: | 
|  | 3999 | throw regex_error(regex_constants::error_collate); | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 | [diff] [blame] | 4000 | #endif // _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | 173968a | 2010-07-13 21:48:06 | [diff] [blame] | 4001 | } | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 4002 | __first = _VSTD::next(__temp, 2); | 
| Howard Hinnant | 0de86b6 | 2010-06-25 20:56:08 | [diff] [blame] | 4003 | return __first; | 
|  | 4004 | } | 
|  | 4005 |  | 
|  | 4006 | template <class _CharT, class _Traits> | 
|  | 4007 | template <class _ForwardIterator> | 
|  | 4008 | _ForwardIterator | 
|  | 4009 | basic_regex<_CharT, _Traits>::__parse_DUP_COUNT(_ForwardIterator __first, | 
|  | 4010 | _ForwardIterator __last, | 
|  | 4011 | int& __c) | 
|  | 4012 | { | 
|  | 4013 | if (__first != __last && '0' <= *__first && *__first <= '9') | 
|  | 4014 | { | 
|  | 4015 | __c = *__first - '0'; | 
|  | 4016 | for (++__first; __first != __last && '0' <= *__first && *__first <= '9'; | 
|  | 4017 | ++__first) | 
|  | 4018 | { | 
|  | 4019 | __c *= 10; | 
|  | 4020 | __c += *__first - '0'; | 
|  | 4021 | } | 
|  | 4022 | } | 
|  | 4023 | return __first; | 
|  | 4024 | } | 
|  | 4025 |  | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 4026 | template <class _CharT, class _Traits> | 
| Howard Hinnant | 2ade7c2 | 2010-07-22 17:53:24 | [diff] [blame] | 4027 | template <class _ForwardIterator> | 
|  | 4028 | _ForwardIterator | 
|  | 4029 | basic_regex<_CharT, _Traits>::__parse_ecma_exp(_ForwardIterator __first, | 
|  | 4030 | _ForwardIterator __last) | 
|  | 4031 | { | 
|  | 4032 | __owns_one_state<_CharT>* __sa = __end_; | 
|  | 4033 | _ForwardIterator __temp = __parse_alternative(__first, __last); | 
|  | 4034 | if (__temp == __first) | 
|  | 4035 | __push_empty(); | 
|  | 4036 | __first = __temp; | 
|  | 4037 | while (__first != __last && *__first == '|') | 
|  | 4038 | { | 
|  | 4039 | __owns_one_state<_CharT>* __sb = __end_; | 
|  | 4040 | __temp = __parse_alternative(++__first, __last); | 
|  | 4041 | if (__temp == __first) | 
|  | 4042 | __push_empty(); | 
|  | 4043 | __push_alternation(__sa, __sb); | 
|  | 4044 | __first = __temp; | 
|  | 4045 | } | 
|  | 4046 | return __first; | 
|  | 4047 | } | 
|  | 4048 |  | 
|  | 4049 | template <class _CharT, class _Traits> | 
|  | 4050 | template <class _ForwardIterator> | 
|  | 4051 | _ForwardIterator | 
|  | 4052 | basic_regex<_CharT, _Traits>::__parse_alternative(_ForwardIterator __first, | 
|  | 4053 | _ForwardIterator __last) | 
|  | 4054 | { | 
|  | 4055 | while (true) | 
|  | 4056 | { | 
|  | 4057 | _ForwardIterator __temp = __parse_term(__first, __last); | 
|  | 4058 | if (__temp == __first) | 
|  | 4059 | break; | 
|  | 4060 | __first = __temp; | 
|  | 4061 | } | 
|  | 4062 | return __first; | 
|  | 4063 | } | 
|  | 4064 |  | 
|  | 4065 | template <class _CharT, class _Traits> | 
|  | 4066 | template <class _ForwardIterator> | 
|  | 4067 | _ForwardIterator | 
|  | 4068 | basic_regex<_CharT, _Traits>::__parse_term(_ForwardIterator __first, | 
|  | 4069 | _ForwardIterator __last) | 
|  | 4070 | { | 
|  | 4071 | _ForwardIterator __temp = __parse_assertion(__first, __last); | 
|  | 4072 | if (__temp == __first) | 
|  | 4073 | { | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 4074 | __owns_one_state<_CharT>* __e = __end_; | 
|  | 4075 | unsigned __mexp_begin = __marked_count_; | 
| Howard Hinnant | 2ade7c2 | 2010-07-22 17:53:24 | [diff] [blame] | 4076 | __temp = __parse_atom(__first, __last); | 
|  | 4077 | if (__temp != __first) | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 4078 | __first = __parse_ERE_dupl_symbol(__temp, __last, __e, | 
|  | 4079 | __mexp_begin+1, __marked_count_+1); | 
| Howard Hinnant | 2ade7c2 | 2010-07-22 17:53:24 | [diff] [blame] | 4080 | } | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 4081 | else | 
|  | 4082 | __first = __temp; | 
| Howard Hinnant | 2ade7c2 | 2010-07-22 17:53:24 | [diff] [blame] | 4083 | return __first; | 
|  | 4084 | } | 
|  | 4085 |  | 
|  | 4086 | template <class _CharT, class _Traits> | 
|  | 4087 | template <class _ForwardIterator> | 
|  | 4088 | _ForwardIterator | 
|  | 4089 | basic_regex<_CharT, _Traits>::__parse_assertion(_ForwardIterator __first, | 
|  | 4090 | _ForwardIterator __last) | 
|  | 4091 | { | 
|  | 4092 | if (__first != __last) | 
|  | 4093 | { | 
|  | 4094 | switch (*__first) | 
|  | 4095 | { | 
|  | 4096 | case '^': | 
|  | 4097 | __push_l_anchor(); | 
|  | 4098 | ++__first; | 
|  | 4099 | break; | 
|  | 4100 | case '$': | 
|  | 4101 | __push_r_anchor(); | 
|  | 4102 | ++__first; | 
|  | 4103 | break; | 
|  | 4104 | case '\\': | 
|  | 4105 | { | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 4106 | _ForwardIterator __temp = _VSTD::next(__first); | 
| Howard Hinnant | 2ade7c2 | 2010-07-22 17:53:24 | [diff] [blame] | 4107 | if (__temp != __last) | 
|  | 4108 | { | 
|  | 4109 | if (*__temp == 'b') | 
|  | 4110 | { | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 4111 | __push_word_boundary(false); | 
| Howard Hinnant | 2ade7c2 | 2010-07-22 17:53:24 | [diff] [blame] | 4112 | __first = ++__temp; | 
|  | 4113 | } | 
|  | 4114 | else if (*__temp == 'B') | 
|  | 4115 | { | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 4116 | __push_word_boundary(true); | 
| Howard Hinnant | 2ade7c2 | 2010-07-22 17:53:24 | [diff] [blame] | 4117 | __first = ++__temp; | 
|  | 4118 | } | 
|  | 4119 | } | 
|  | 4120 | } | 
|  | 4121 | break; | 
|  | 4122 | case '(': | 
|  | 4123 | { | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 4124 | _ForwardIterator __temp = _VSTD::next(__first); | 
| Howard Hinnant | 2ade7c2 | 2010-07-22 17:53:24 | [diff] [blame] | 4125 | if (__temp != __last && *__temp == '?') | 
|  | 4126 | { | 
|  | 4127 | if (++__temp != __last) | 
|  | 4128 | { | 
|  | 4129 | switch (*__temp) | 
|  | 4130 | { | 
|  | 4131 | case '=': | 
| Howard Hinnant | e9de5ff | 2010-07-27 22:20:32 | [diff] [blame] | 4132 | { | 
|  | 4133 | basic_regex __exp; | 
|  | 4134 | __exp.__flags_ = __flags_; | 
|  | 4135 | __temp = __exp.__parse(++__temp, __last); | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 4136 | __push_lookahead(_VSTD::move(__exp), false); | 
| Howard Hinnant | d444470 | 2010-08-11 17:04:31 | [diff] [blame] | 4137 | #ifndef _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | e9de5ff | 2010-07-27 22:20:32 | [diff] [blame] | 4138 | if (__temp == __last || *__temp != ')') | 
|  | 4139 | throw regex_error(regex_constants::error_paren); | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 | [diff] [blame] | 4140 | #endif // _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | e9de5ff | 2010-07-27 22:20:32 | [diff] [blame] | 4141 | __first = ++__temp; | 
|  | 4142 | } | 
| Howard Hinnant | 2ade7c2 | 2010-07-22 17:53:24 | [diff] [blame] | 4143 | break; | 
|  | 4144 | case '!': | 
| Howard Hinnant | e9de5ff | 2010-07-27 22:20:32 | [diff] [blame] | 4145 | { | 
|  | 4146 | basic_regex __exp; | 
|  | 4147 | __exp.__flags_ = __flags_; | 
|  | 4148 | __temp = __exp.__parse(++__temp, __last); | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 4149 | __push_lookahead(_VSTD::move(__exp), true); | 
| Howard Hinnant | d444470 | 2010-08-11 17:04:31 | [diff] [blame] | 4150 | #ifndef _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | e9de5ff | 2010-07-27 22:20:32 | [diff] [blame] | 4151 | if (__temp == __last || *__temp != ')') | 
|  | 4152 | throw regex_error(regex_constants::error_paren); | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 | [diff] [blame] | 4153 | #endif // _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | e9de5ff | 2010-07-27 22:20:32 | [diff] [blame] | 4154 | __first = ++__temp; | 
|  | 4155 | } | 
| Howard Hinnant | 2ade7c2 | 2010-07-22 17:53:24 | [diff] [blame] | 4156 | break; | 
|  | 4157 | } | 
|  | 4158 | } | 
|  | 4159 | } | 
|  | 4160 | } | 
|  | 4161 | break; | 
|  | 4162 | } | 
|  | 4163 | } | 
|  | 4164 | return __first; | 
|  | 4165 | } | 
|  | 4166 |  | 
|  | 4167 | template <class _CharT, class _Traits> | 
|  | 4168 | template <class _ForwardIterator> | 
|  | 4169 | _ForwardIterator | 
|  | 4170 | basic_regex<_CharT, _Traits>::__parse_atom(_ForwardIterator __first, | 
|  | 4171 | _ForwardIterator __last) | 
|  | 4172 | { | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 4173 | if (__first != __last) | 
|  | 4174 | { | 
|  | 4175 | switch (*__first) | 
|  | 4176 | { | 
|  | 4177 | case '.': | 
|  | 4178 | __push_match_any_but_newline(); | 
|  | 4179 | ++__first; | 
|  | 4180 | break; | 
|  | 4181 | case '\\': | 
|  | 4182 | __first = __parse_atom_escape(__first, __last); | 
|  | 4183 | break; | 
|  | 4184 | case '[': | 
|  | 4185 | __first = __parse_bracket_expression(__first, __last); | 
|  | 4186 | break; | 
|  | 4187 | case '(': | 
|  | 4188 | { | 
| Howard Hinnant | d444470 | 2010-08-11 17:04:31 | [diff] [blame] | 4189 | ++__first; | 
|  | 4190 | #ifndef _LIBCPP_NO_EXCEPTIONS | 
|  | 4191 | if (__first == __last) | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 4192 | throw regex_error(regex_constants::error_paren); | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 | [diff] [blame] | 4193 | #endif // _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 4194 | _ForwardIterator __temp = _VSTD::next(__first); | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 4195 | if (__temp != __last && *__first == '?' && *__temp == ':') | 
|  | 4196 | { | 
|  | 4197 | ++__open_count_; | 
|  | 4198 | __first = __parse_ecma_exp(++__temp, __last); | 
| Howard Hinnant | d444470 | 2010-08-11 17:04:31 | [diff] [blame] | 4199 | #ifndef _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 4200 | if (__first == __last || *__first != ')') | 
|  | 4201 | throw regex_error(regex_constants::error_paren); | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 | [diff] [blame] | 4202 | #endif // _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 4203 | --__open_count_; | 
|  | 4204 | ++__first; | 
|  | 4205 | } | 
|  | 4206 | else | 
|  | 4207 | { | 
|  | 4208 | __push_begin_marked_subexpression(); | 
|  | 4209 | unsigned __temp_count = __marked_count_; | 
|  | 4210 | ++__open_count_; | 
|  | 4211 | __first = __parse_ecma_exp(__first, __last); | 
| Howard Hinnant | d444470 | 2010-08-11 17:04:31 | [diff] [blame] | 4212 | #ifndef _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 4213 | if (__first == __last || *__first != ')') | 
|  | 4214 | throw regex_error(regex_constants::error_paren); | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 | [diff] [blame] | 4215 | #endif // _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 4216 | __push_end_marked_subexpression(__temp_count); | 
|  | 4217 | --__open_count_; | 
|  | 4218 | ++__first; | 
|  | 4219 | } | 
|  | 4220 | } | 
|  | 4221 | break; | 
|  | 4222 | default: | 
|  | 4223 | __first = __parse_pattern_character(__first, __last); | 
|  | 4224 | break; | 
|  | 4225 | } | 
|  | 4226 | } | 
|  | 4227 | return __first; | 
|  | 4228 | } | 
|  | 4229 |  | 
|  | 4230 | template <class _CharT, class _Traits> | 
|  | 4231 | template <class _ForwardIterator> | 
|  | 4232 | _ForwardIterator | 
|  | 4233 | basic_regex<_CharT, _Traits>::__parse_atom_escape(_ForwardIterator __first, | 
|  | 4234 | _ForwardIterator __last) | 
|  | 4235 | { | 
|  | 4236 | if (__first != __last && *__first == '\\') | 
|  | 4237 | { | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 4238 | _ForwardIterator __t1 = _VSTD::next(__first); | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 4239 | _ForwardIterator __t2 = __parse_decimal_escape(__t1, __last); | 
|  | 4240 | if (__t2 != __t1) | 
|  | 4241 | __first = __t2; | 
|  | 4242 | else | 
|  | 4243 | { | 
|  | 4244 | __t2 = __parse_character_class_escape(__t1, __last); | 
|  | 4245 | if (__t2 != __t1) | 
|  | 4246 | __first = __t2; | 
|  | 4247 | else | 
|  | 4248 | { | 
|  | 4249 | __t2 = __parse_character_escape(__t1, __last); | 
|  | 4250 | if (__t2 != __t1) | 
|  | 4251 | __first = __t2; | 
|  | 4252 | } | 
|  | 4253 | } | 
|  | 4254 | } | 
|  | 4255 | return __first; | 
|  | 4256 | } | 
|  | 4257 |  | 
|  | 4258 | template <class _CharT, class _Traits> | 
|  | 4259 | template <class _ForwardIterator> | 
|  | 4260 | _ForwardIterator | 
|  | 4261 | basic_regex<_CharT, _Traits>::__parse_decimal_escape(_ForwardIterator __first, | 
|  | 4262 | _ForwardIterator __last) | 
|  | 4263 | { | 
|  | 4264 | if (__first != __last) | 
|  | 4265 | { | 
|  | 4266 | if (*__first == '0') | 
|  | 4267 | { | 
|  | 4268 | __push_char(_CharT()); | 
|  | 4269 | ++__first; | 
|  | 4270 | } | 
|  | 4271 | else if ('1' <= *__first && *__first <= '9') | 
|  | 4272 | { | 
|  | 4273 | unsigned __v = *__first - '0'; | 
|  | 4274 | for (++__first; '0' <= *__first && *__first <= '9'; ++__first) | 
|  | 4275 | __v = 10 * __v + *__first - '0'; | 
| Howard Hinnant | d444470 | 2010-08-11 17:04:31 | [diff] [blame] | 4276 | #ifndef _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 4277 | if (__v > mark_count()) | 
|  | 4278 | throw regex_error(regex_constants::error_backref); | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 | [diff] [blame] | 4279 | #endif // _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 4280 | __push_back_ref(__v); | 
|  | 4281 | } | 
|  | 4282 | } | 
|  | 4283 | return __first; | 
|  | 4284 | } | 
|  | 4285 |  | 
|  | 4286 | template <class _CharT, class _Traits> | 
|  | 4287 | template <class _ForwardIterator> | 
|  | 4288 | _ForwardIterator | 
|  | 4289 | basic_regex<_CharT, _Traits>::__parse_character_class_escape(_ForwardIterator __first, | 
|  | 4290 | _ForwardIterator __last) | 
|  | 4291 | { | 
|  | 4292 | if (__first != __last) | 
|  | 4293 | { | 
|  | 4294 | __bracket_expression<_CharT, _Traits>* __ml; | 
|  | 4295 | switch (*__first) | 
|  | 4296 | { | 
|  | 4297 | case 'd': | 
|  | 4298 | __ml = __start_matching_list(false); | 
|  | 4299 | __ml->__add_class(ctype_base::digit); | 
|  | 4300 | ++__first; | 
|  | 4301 | break; | 
|  | 4302 | case 'D': | 
|  | 4303 | __ml = __start_matching_list(true); | 
|  | 4304 | __ml->__add_class(ctype_base::digit); | 
|  | 4305 | ++__first; | 
|  | 4306 | break; | 
|  | 4307 | case 's': | 
|  | 4308 | __ml = __start_matching_list(false); | 
|  | 4309 | __ml->__add_class(ctype_base::space); | 
|  | 4310 | ++__first; | 
|  | 4311 | break; | 
|  | 4312 | case 'S': | 
|  | 4313 | __ml = __start_matching_list(true); | 
|  | 4314 | __ml->__add_class(ctype_base::space); | 
|  | 4315 | ++__first; | 
|  | 4316 | break; | 
|  | 4317 | case 'w': | 
|  | 4318 | __ml = __start_matching_list(false); | 
|  | 4319 | __ml->__add_class(ctype_base::alnum); | 
|  | 4320 | __ml->__add_char('_'); | 
|  | 4321 | ++__first; | 
|  | 4322 | break; | 
|  | 4323 | case 'W': | 
|  | 4324 | __ml = __start_matching_list(true); | 
|  | 4325 | __ml->__add_class(ctype_base::alnum); | 
|  | 4326 | __ml->__add_char('_'); | 
|  | 4327 | ++__first; | 
|  | 4328 | break; | 
|  | 4329 | } | 
|  | 4330 | } | 
|  | 4331 | return __first; | 
|  | 4332 | } | 
|  | 4333 |  | 
|  | 4334 | template <class _CharT, class _Traits> | 
|  | 4335 | template <class _ForwardIterator> | 
|  | 4336 | _ForwardIterator | 
|  | 4337 | basic_regex<_CharT, _Traits>::__parse_character_escape(_ForwardIterator __first, | 
| Howard Hinnant | 15476f3 | 2010-07-28 17:35:27 | [diff] [blame] | 4338 | _ForwardIterator __last, | 
|  | 4339 | basic_string<_CharT>* __str) | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 4340 | { | 
|  | 4341 | if (__first != __last) | 
|  | 4342 | { | 
|  | 4343 | _ForwardIterator __t; | 
|  | 4344 | unsigned __sum = 0; | 
|  | 4345 | int __hd; | 
|  | 4346 | switch (*__first) | 
|  | 4347 | { | 
|  | 4348 | case 'f': | 
| Howard Hinnant | 15476f3 | 2010-07-28 17:35:27 | [diff] [blame] | 4349 | if (__str) | 
|  | 4350 | *__str = _CharT(0xC); | 
|  | 4351 | else | 
|  | 4352 | __push_char(_CharT(0xC)); | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 4353 | ++__first; | 
|  | 4354 | break; | 
|  | 4355 | case 'n': | 
| Howard Hinnant | 15476f3 | 2010-07-28 17:35:27 | [diff] [blame] | 4356 | if (__str) | 
|  | 4357 | *__str = _CharT(0xA); | 
|  | 4358 | else | 
|  | 4359 | __push_char(_CharT(0xA)); | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 4360 | ++__first; | 
|  | 4361 | break; | 
|  | 4362 | case 'r': | 
| Howard Hinnant | 15476f3 | 2010-07-28 17:35:27 | [diff] [blame] | 4363 | if (__str) | 
|  | 4364 | *__str = _CharT(0xD); | 
|  | 4365 | else | 
|  | 4366 | __push_char(_CharT(0xD)); | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 4367 | ++__first; | 
|  | 4368 | break; | 
|  | 4369 | case 't': | 
| Howard Hinnant | 15476f3 | 2010-07-28 17:35:27 | [diff] [blame] | 4370 | if (__str) | 
|  | 4371 | *__str = _CharT(0x9); | 
|  | 4372 | else | 
|  | 4373 | __push_char(_CharT(0x9)); | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 4374 | ++__first; | 
|  | 4375 | break; | 
|  | 4376 | case 'v': | 
| Howard Hinnant | 15476f3 | 2010-07-28 17:35:27 | [diff] [blame] | 4377 | if (__str) | 
|  | 4378 | *__str = _CharT(0xB); | 
|  | 4379 | else | 
|  | 4380 | __push_char(_CharT(0xB)); | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 4381 | ++__first; | 
|  | 4382 | break; | 
|  | 4383 | case 'c': | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 4384 | if ((__t = _VSTD::next(__first)) != __last) | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 4385 | { | 
|  | 4386 | if ('A' <= *__t <= 'Z' || 'a' <= *__t <= 'z') | 
|  | 4387 | { | 
| Howard Hinnant | 15476f3 | 2010-07-28 17:35:27 | [diff] [blame] | 4388 | if (__str) | 
|  | 4389 | *__str = _CharT(*__t % 32); | 
|  | 4390 | else | 
|  | 4391 | __push_char(_CharT(*__t % 32)); | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 4392 | __first = ++__t; | 
|  | 4393 | } | 
|  | 4394 | } | 
|  | 4395 | break; | 
|  | 4396 | case 'u': | 
| Howard Hinnant | d444470 | 2010-08-11 17:04:31 | [diff] [blame] | 4397 | ++__first; | 
|  | 4398 | #ifndef _LIBCPP_NO_EXCEPTIONS | 
|  | 4399 | if (__first == __last) | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 4400 | throw regex_error(regex_constants::error_escape); | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 | [diff] [blame] | 4401 | #endif // _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 4402 | __hd = __traits_.value(*__first, 16); | 
| Howard Hinnant | d444470 | 2010-08-11 17:04:31 | [diff] [blame] | 4403 | #ifndef _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 4404 | if (__hd == -1) | 
|  | 4405 | throw regex_error(regex_constants::error_escape); | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 | [diff] [blame] | 4406 | #endif // _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | ec3773c | 2011-12-01 20:21:04 | [diff] [blame] | 4407 | __sum = 16 * __sum + static_cast<unsigned>(__hd); | 
| Howard Hinnant | d444470 | 2010-08-11 17:04:31 | [diff] [blame] | 4408 | ++__first; | 
|  | 4409 | #ifndef _LIBCPP_NO_EXCEPTIONS | 
|  | 4410 | if (__first == __last) | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 4411 | throw regex_error(regex_constants::error_escape); | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 | [diff] [blame] | 4412 | #endif // _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 4413 | __hd = __traits_.value(*__first, 16); | 
| Howard Hinnant | d444470 | 2010-08-11 17:04:31 | [diff] [blame] | 4414 | #ifndef _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 4415 | if (__hd == -1) | 
|  | 4416 | throw regex_error(regex_constants::error_escape); | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 | [diff] [blame] | 4417 | #endif // _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | ec3773c | 2011-12-01 20:21:04 | [diff] [blame] | 4418 | __sum = 16 * __sum + static_cast<unsigned>(__hd); | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 4419 | // drop through | 
|  | 4420 | case 'x': | 
| Howard Hinnant | d444470 | 2010-08-11 17:04:31 | [diff] [blame] | 4421 | ++__first; | 
|  | 4422 | #ifndef _LIBCPP_NO_EXCEPTIONS | 
|  | 4423 | if (__first == __last) | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 4424 | throw regex_error(regex_constants::error_escape); | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 | [diff] [blame] | 4425 | #endif // _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 4426 | __hd = __traits_.value(*__first, 16); | 
| Howard Hinnant | d444470 | 2010-08-11 17:04:31 | [diff] [blame] | 4427 | #ifndef _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 4428 | if (__hd == -1) | 
|  | 4429 | throw regex_error(regex_constants::error_escape); | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 | [diff] [blame] | 4430 | #endif // _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | ec3773c | 2011-12-01 20:21:04 | [diff] [blame] | 4431 | __sum = 16 * __sum + static_cast<unsigned>(__hd); | 
| Howard Hinnant | d444470 | 2010-08-11 17:04:31 | [diff] [blame] | 4432 | ++__first; | 
|  | 4433 | #ifndef _LIBCPP_NO_EXCEPTIONS | 
|  | 4434 | if (__first == __last) | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 4435 | throw regex_error(regex_constants::error_escape); | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 | [diff] [blame] | 4436 | #endif // _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 4437 | __hd = __traits_.value(*__first, 16); | 
| Howard Hinnant | d444470 | 2010-08-11 17:04:31 | [diff] [blame] | 4438 | #ifndef _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 4439 | if (__hd == -1) | 
|  | 4440 | throw regex_error(regex_constants::error_escape); | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 | [diff] [blame] | 4441 | #endif // _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | ec3773c | 2011-12-01 20:21:04 | [diff] [blame] | 4442 | __sum = 16 * __sum + static_cast<unsigned>(__hd); | 
| Howard Hinnant | 15476f3 | 2010-07-28 17:35:27 | [diff] [blame] | 4443 | if (__str) | 
|  | 4444 | *__str = _CharT(__sum); | 
|  | 4445 | else | 
|  | 4446 | __push_char(_CharT(__sum)); | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 4447 | ++__first; | 
|  | 4448 | break; | 
|  | 4449 | default: | 
|  | 4450 | if (*__first != '_' && !__traits_.isctype(*__first, ctype_base::alnum)) | 
|  | 4451 | { | 
| Howard Hinnant | 15476f3 | 2010-07-28 17:35:27 | [diff] [blame] | 4452 | if (__str) | 
|  | 4453 | *__str = *__first; | 
|  | 4454 | else | 
|  | 4455 | __push_char(*__first); | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 4456 | ++__first; | 
|  | 4457 | } | 
| Howard Hinnant | d444470 | 2010-08-11 17:04:31 | [diff] [blame] | 4458 | #ifndef _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | 15476f3 | 2010-07-28 17:35:27 | [diff] [blame] | 4459 | else if (__str) | 
|  | 4460 | throw regex_error(regex_constants::error_escape); | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 | [diff] [blame] | 4461 | #endif // _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 4462 | break; | 
|  | 4463 | } | 
|  | 4464 | } | 
|  | 4465 | return __first; | 
|  | 4466 | } | 
|  | 4467 |  | 
|  | 4468 | template <class _CharT, class _Traits> | 
|  | 4469 | template <class _ForwardIterator> | 
|  | 4470 | _ForwardIterator | 
|  | 4471 | basic_regex<_CharT, _Traits>::__parse_pattern_character(_ForwardIterator __first, | 
|  | 4472 | _ForwardIterator __last) | 
|  | 4473 | { | 
|  | 4474 | if (__first != __last) | 
|  | 4475 | { | 
|  | 4476 | switch (*__first) | 
|  | 4477 | { | 
|  | 4478 | case '^': | 
|  | 4479 | case '$': | 
|  | 4480 | case '\\': | 
|  | 4481 | case '.': | 
|  | 4482 | case '*': | 
|  | 4483 | case '+': | 
|  | 4484 | case '?': | 
|  | 4485 | case '(': | 
|  | 4486 | case ')': | 
|  | 4487 | case '[': | 
|  | 4488 | case ']': | 
|  | 4489 | case '{': | 
|  | 4490 | case '}': | 
|  | 4491 | case '|': | 
|  | 4492 | break; | 
|  | 4493 | default: | 
|  | 4494 | __push_char(*__first); | 
|  | 4495 | ++__first; | 
|  | 4496 | break; | 
|  | 4497 | } | 
|  | 4498 | } | 
|  | 4499 | return __first; | 
| Howard Hinnant | 2ade7c2 | 2010-07-22 17:53:24 | [diff] [blame] | 4500 | } | 
|  | 4501 |  | 
|  | 4502 | template <class _CharT, class _Traits> | 
| Howard Hinnant | 856846b | 2010-07-27 19:53:10 | [diff] [blame] | 4503 | template <class _ForwardIterator> | 
|  | 4504 | _ForwardIterator | 
|  | 4505 | basic_regex<_CharT, _Traits>::__parse_grep(_ForwardIterator __first, | 
|  | 4506 | _ForwardIterator __last) | 
|  | 4507 | { | 
|  | 4508 | __owns_one_state<_CharT>* __sa = __end_; | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 4509 | _ForwardIterator __t1 = _VSTD::find(__first, __last, _CharT('\n')); | 
| Howard Hinnant | 856846b | 2010-07-27 19:53:10 | [diff] [blame] | 4510 | if (__t1 != __first) | 
|  | 4511 | __parse_basic_reg_exp(__first, __t1); | 
|  | 4512 | else | 
|  | 4513 | __push_empty(); | 
|  | 4514 | __first = __t1; | 
|  | 4515 | if (__first != __last) | 
|  | 4516 | ++__first; | 
|  | 4517 | while (__first != __last) | 
|  | 4518 | { | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 4519 | __t1 = _VSTD::find(__first, __last, _CharT('\n')); | 
| Howard Hinnant | 856846b | 2010-07-27 19:53:10 | [diff] [blame] | 4520 | __owns_one_state<_CharT>* __sb = __end_; | 
|  | 4521 | if (__t1 != __first) | 
|  | 4522 | __parse_basic_reg_exp(__first, __t1); | 
|  | 4523 | else | 
|  | 4524 | __push_empty(); | 
|  | 4525 | __push_alternation(__sa, __sb); | 
|  | 4526 | __first = __t1; | 
|  | 4527 | if (__first != __last) | 
|  | 4528 | ++__first; | 
|  | 4529 | } | 
|  | 4530 | return __first; | 
|  | 4531 | } | 
|  | 4532 |  | 
|  | 4533 | template <class _CharT, class _Traits> | 
|  | 4534 | template <class _ForwardIterator> | 
|  | 4535 | _ForwardIterator | 
|  | 4536 | basic_regex<_CharT, _Traits>::__parse_egrep(_ForwardIterator __first, | 
|  | 4537 | _ForwardIterator __last) | 
|  | 4538 | { | 
|  | 4539 | __owns_one_state<_CharT>* __sa = __end_; | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 4540 | _ForwardIterator __t1 = _VSTD::find(__first, __last, _CharT('\n')); | 
| Howard Hinnant | 856846b | 2010-07-27 19:53:10 | [diff] [blame] | 4541 | if (__t1 != __first) | 
|  | 4542 | __parse_extended_reg_exp(__first, __t1); | 
|  | 4543 | else | 
|  | 4544 | __push_empty(); | 
|  | 4545 | __first = __t1; | 
|  | 4546 | if (__first != __last) | 
|  | 4547 | ++__first; | 
|  | 4548 | while (__first != __last) | 
|  | 4549 | { | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 4550 | __t1 = _VSTD::find(__first, __last, _CharT('\n')); | 
| Howard Hinnant | 856846b | 2010-07-27 19:53:10 | [diff] [blame] | 4551 | __owns_one_state<_CharT>* __sb = __end_; | 
|  | 4552 | if (__t1 != __first) | 
|  | 4553 | __parse_extended_reg_exp(__first, __t1); | 
|  | 4554 | else | 
|  | 4555 | __push_empty(); | 
|  | 4556 | __push_alternation(__sa, __sb); | 
|  | 4557 | __first = __t1; | 
|  | 4558 | if (__first != __last) | 
|  | 4559 | ++__first; | 
|  | 4560 | } | 
|  | 4561 | return __first; | 
|  | 4562 | } | 
|  | 4563 |  | 
|  | 4564 | template <class _CharT, class _Traits> | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 4565 | void | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 4566 | basic_regex<_CharT, _Traits>::__push_loop(size_t __min, size_t __max, | 
|  | 4567 | __owns_one_state<_CharT>* __s, size_t __mexp_begin, size_t __mexp_end, | 
|  | 4568 | bool __greedy) | 
|  | 4569 | { | 
|  | 4570 | unique_ptr<__empty_state<_CharT> > __e1(new __empty_state<_CharT>(__end_->first())); | 
|  | 4571 | __end_->first() = nullptr; | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 4572 | unique_ptr<__loop<_CharT> > __e2(new __loop<_CharT>(__loop_count_, | 
|  | 4573 | __s->first(), __e1.get(), __mexp_begin, __mexp_end, __greedy, | 
|  | 4574 | __min, __max)); | 
|  | 4575 | __s->first() = nullptr; | 
|  | 4576 | __e1.release(); | 
|  | 4577 | __end_->first() = new __repeat_one_loop<_CharT>(__e2.get()); | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 4578 | __end_ = __e2->second(); | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 4579 | __s->first() = __e2.release(); | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 4580 | ++__loop_count_; | 
|  | 4581 | } | 
|  | 4582 |  | 
|  | 4583 | template <class _CharT, class _Traits> | 
|  | 4584 | void | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 4585 | basic_regex<_CharT, _Traits>::__push_char(value_type __c) | 
|  | 4586 | { | 
| Howard Hinnant | 173968a | 2010-07-13 21:48:06 | [diff] [blame] | 4587 | if (flags() & icase) | 
| Howard Hinnant | e34f17d | 2010-07-12 19:11:27 | [diff] [blame] | 4588 | __end_->first() = new __match_char_icase<_CharT, _Traits> | 
|  | 4589 | (__traits_, __c, __end_->first()); | 
| Howard Hinnant | 173968a | 2010-07-13 21:48:06 | [diff] [blame] | 4590 | else if (flags() & collate) | 
| Howard Hinnant | e34f17d | 2010-07-12 19:11:27 | [diff] [blame] | 4591 | __end_->first() = new __match_char_collate<_CharT, _Traits> | 
|  | 4592 | (__traits_, __c, __end_->first()); | 
|  | 4593 | else | 
|  | 4594 | __end_->first() = new __match_char<_CharT>(__c, __end_->first()); | 
| Howard Hinnant | e77aa5e | 2010-07-08 17:43:58 | [diff] [blame] | 4595 | __end_ = static_cast<__owns_one_state<_CharT>*>(__end_->first()); | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 4596 | } | 
|  | 4597 |  | 
| Howard Hinnant | 0dca5fc | 2010-06-30 20:30:19 | [diff] [blame] | 4598 | template <class _CharT, class _Traits> | 
|  | 4599 | void | 
|  | 4600 | basic_regex<_CharT, _Traits>::__push_begin_marked_subexpression() | 
|  | 4601 | { | 
| Howard Hinnant | 68025ed | 2010-07-14 15:45:11 | [diff] [blame] | 4602 | if (!(__flags_ & nosubs)) | 
|  | 4603 | { | 
|  | 4604 | __end_->first() = | 
|  | 4605 | new __begin_marked_subexpression<_CharT>(++__marked_count_, | 
|  | 4606 | __end_->first()); | 
|  | 4607 | __end_ = static_cast<__owns_one_state<_CharT>*>(__end_->first()); | 
|  | 4608 | } | 
| Howard Hinnant | 0dca5fc | 2010-06-30 20:30:19 | [diff] [blame] | 4609 | } | 
|  | 4610 |  | 
|  | 4611 | template <class _CharT, class _Traits> | 
|  | 4612 | void | 
|  | 4613 | basic_regex<_CharT, _Traits>::__push_end_marked_subexpression(unsigned __sub) | 
|  | 4614 | { | 
| Howard Hinnant | 68025ed | 2010-07-14 15:45:11 | [diff] [blame] | 4615 | if (!(__flags_ & nosubs)) | 
|  | 4616 | { | 
|  | 4617 | __end_->first() = | 
|  | 4618 | new __end_marked_subexpression<_CharT>(__sub, __end_->first()); | 
|  | 4619 | __end_ = static_cast<__owns_one_state<_CharT>*>(__end_->first()); | 
|  | 4620 | } | 
| Howard Hinnant | 0dca5fc | 2010-06-30 20:30:19 | [diff] [blame] | 4621 | } | 
|  | 4622 |  | 
| Howard Hinnant | 37f9f9c | 2010-07-09 00:15:26 | [diff] [blame] | 4623 | template <class _CharT, class _Traits> | 
|  | 4624 | void | 
| Howard Hinnant | 41fb6e1 | 2011-03-26 20:02:27 | [diff] [blame] | 4625 | basic_regex<_CharT, _Traits>::__push_l_anchor() | 
|  | 4626 | { | 
|  | 4627 | __end_->first() = new __l_anchor<_CharT>(__end_->first()); | 
|  | 4628 | __end_ = static_cast<__owns_one_state<_CharT>*>(__end_->first()); | 
|  | 4629 | } | 
|  | 4630 |  | 
|  | 4631 | template <class _CharT, class _Traits> | 
|  | 4632 | void | 
| Howard Hinnant | 37f9f9c | 2010-07-09 00:15:26 | [diff] [blame] | 4633 | basic_regex<_CharT, _Traits>::__push_r_anchor() | 
|  | 4634 | { | 
|  | 4635 | __end_->first() = new __r_anchor<_CharT>(__end_->first()); | 
|  | 4636 | __end_ = static_cast<__owns_one_state<_CharT>*>(__end_->first()); | 
|  | 4637 | } | 
|  | 4638 |  | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 4639 | template <class _CharT, class _Traits> | 
|  | 4640 | void | 
|  | 4641 | basic_regex<_CharT, _Traits>::__push_match_any() | 
|  | 4642 | { | 
|  | 4643 | __end_->first() = new __match_any<_CharT>(__end_->first()); | 
|  | 4644 | __end_ = static_cast<__owns_one_state<_CharT>*>(__end_->first()); | 
|  | 4645 | } | 
| Howard Hinnant | 37f9f9c | 2010-07-09 00:15:26 | [diff] [blame] | 4646 |  | 
| Howard Hinnant | cba352d | 2010-07-12 18:16:05 | [diff] [blame] | 4647 | template <class _CharT, class _Traits> | 
|  | 4648 | void | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 4649 | basic_regex<_CharT, _Traits>::__push_match_any_but_newline() | 
|  | 4650 | { | 
|  | 4651 | __end_->first() = new __match_any_but_newline<_CharT>(__end_->first()); | 
|  | 4652 | __end_ = static_cast<__owns_one_state<_CharT>*>(__end_->first()); | 
|  | 4653 | } | 
|  | 4654 |  | 
|  | 4655 | template <class _CharT, class _Traits> | 
|  | 4656 | void | 
| Howard Hinnant | 2ade7c2 | 2010-07-22 17:53:24 | [diff] [blame] | 4657 | basic_regex<_CharT, _Traits>::__push_empty() | 
|  | 4658 | { | 
|  | 4659 | __end_->first() = new __empty_state<_CharT>(__end_->first()); | 
|  | 4660 | __end_ = static_cast<__owns_one_state<_CharT>*>(__end_->first()); | 
|  | 4661 | } | 
|  | 4662 |  | 
|  | 4663 | template <class _CharT, class _Traits> | 
|  | 4664 | void | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 4665 | basic_regex<_CharT, _Traits>::__push_word_boundary(bool __invert) | 
|  | 4666 | { | 
|  | 4667 | __end_->first() = new __word_boundary<_CharT, _Traits>(__traits_, __invert, | 
|  | 4668 | __end_->first()); | 
|  | 4669 | __end_ = static_cast<__owns_one_state<_CharT>*>(__end_->first()); | 
|  | 4670 | } | 
|  | 4671 |  | 
|  | 4672 | template <class _CharT, class _Traits> | 
|  | 4673 | void | 
| Howard Hinnant | cba352d | 2010-07-12 18:16:05 | [diff] [blame] | 4674 | basic_regex<_CharT, _Traits>::__push_back_ref(int __i) | 
|  | 4675 | { | 
| Howard Hinnant | 173968a | 2010-07-13 21:48:06 | [diff] [blame] | 4676 | if (flags() & icase) | 
| Howard Hinnant | e34f17d | 2010-07-12 19:11:27 | [diff] [blame] | 4677 | __end_->first() = new __back_ref_icase<_CharT, _Traits> | 
|  | 4678 | (__traits_, __i, __end_->first()); | 
| Howard Hinnant | 173968a | 2010-07-13 21:48:06 | [diff] [blame] | 4679 | else if (flags() & collate) | 
| Howard Hinnant | e34f17d | 2010-07-12 19:11:27 | [diff] [blame] | 4680 | __end_->first() = new __back_ref_collate<_CharT, _Traits> | 
|  | 4681 | (__traits_, __i, __end_->first()); | 
|  | 4682 | else | 
|  | 4683 | __end_->first() = new __back_ref<_CharT>(__i, __end_->first()); | 
| Howard Hinnant | cba352d | 2010-07-12 18:16:05 | [diff] [blame] | 4684 | __end_ = static_cast<__owns_one_state<_CharT>*>(__end_->first()); | 
|  | 4685 | } | 
|  | 4686 |  | 
| Howard Hinnant | 173968a | 2010-07-13 21:48:06 | [diff] [blame] | 4687 | template <class _CharT, class _Traits> | 
| Howard Hinnant | aa69808 | 2010-07-16 19:08:36 | [diff] [blame] | 4688 | void | 
|  | 4689 | basic_regex<_CharT, _Traits>::__push_alternation(__owns_one_state<_CharT>* __sa, | 
|  | 4690 | __owns_one_state<_CharT>* __ea) | 
|  | 4691 | { | 
|  | 4692 | __sa->first() = new __alternate<_CharT>( | 
|  | 4693 | static_cast<__owns_one_state<_CharT>*>(__sa->first()), | 
|  | 4694 | static_cast<__owns_one_state<_CharT>*>(__ea->first())); | 
|  | 4695 | __ea->first() = nullptr; | 
|  | 4696 | __ea->first() = new __empty_state<_CharT>(__end_->first()); | 
|  | 4697 | __end_->first() = nullptr; | 
|  | 4698 | __end_->first() = new __empty_non_own_state<_CharT>(__ea->first()); | 
|  | 4699 | __end_ = static_cast<__owns_one_state<_CharT>*>(__ea->first()); | 
|  | 4700 | } | 
|  | 4701 |  | 
|  | 4702 | template <class _CharT, class _Traits> | 
| Howard Hinnant | 173968a | 2010-07-13 21:48:06 | [diff] [blame] | 4703 | __bracket_expression<_CharT, _Traits>* | 
|  | 4704 | basic_regex<_CharT, _Traits>::__start_matching_list(bool __negate) | 
|  | 4705 | { | 
|  | 4706 | __bracket_expression<_CharT, _Traits>* __r = | 
|  | 4707 | new __bracket_expression<_CharT, _Traits>(__traits_, __end_->first(), | 
|  | 4708 | __negate, __flags_ & icase, | 
|  | 4709 | __flags_ & collate); | 
|  | 4710 | __end_->first() = __r; | 
|  | 4711 | __end_ = __r; | 
|  | 4712 | return __r; | 
|  | 4713 | } | 
|  | 4714 |  | 
| Howard Hinnant | e9de5ff | 2010-07-27 22:20:32 | [diff] [blame] | 4715 | template <class _CharT, class _Traits> | 
|  | 4716 | void | 
|  | 4717 | basic_regex<_CharT, _Traits>::__push_lookahead(const basic_regex& __exp, | 
|  | 4718 | bool __invert) | 
|  | 4719 | { | 
|  | 4720 | __end_->first() = new __lookahead<_CharT, _Traits>(__exp, __invert, | 
|  | 4721 | __end_->first()); | 
|  | 4722 | __end_ = static_cast<__owns_one_state<_CharT>*>(__end_->first()); | 
|  | 4723 | } | 
|  | 4724 |  | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 4725 | typedef basic_regex<char> regex; | 
|  | 4726 | typedef basic_regex<wchar_t> wregex; | 
|  | 4727 |  | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 4728 | // sub_match | 
|  | 4729 |  | 
|  | 4730 | template <class _BidirectionalIterator> | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 4731 | class _LIBCPP_VISIBLE sub_match | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 4732 | : public pair<_BidirectionalIterator, _BidirectionalIterator> | 
|  | 4733 | { | 
|  | 4734 | public: | 
|  | 4735 | typedef _BidirectionalIterator iterator; | 
|  | 4736 | typedef typename iterator_traits<iterator>::value_type value_type; | 
|  | 4737 | typedef typename iterator_traits<iterator>::difference_type difference_type; | 
|  | 4738 | typedef basic_string<value_type> string_type; | 
|  | 4739 |  | 
|  | 4740 | bool matched; | 
|  | 4741 |  | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 4742 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 46623a0 | 2012-07-21 01:31:58 | [diff] [blame] | 4743 | _LIBCPP_CONSTEXPR sub_match() : matched() {} | 
| Howard Hinnant | 31aaf55 | 2010-12-08 21:07:55 | [diff] [blame] | 4744 |  | 
|  | 4745 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 4746 | difference_type length() const | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 4747 | {return matched ? _VSTD::distance(this->first, this->second) : 0;} | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 4748 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 4749 | string_type str() const | 
|  | 4750 | {return matched ? string_type(this->first, this->second) : string_type();} | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 4751 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 4752 | operator string_type() const | 
|  | 4753 | {return str();} | 
|  | 4754 |  | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 4755 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 4756 | int compare(const sub_match& __s) const | 
|  | 4757 | {return str().compare(__s.str());} | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 4758 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 4759 | int compare(const string_type& __s) const | 
|  | 4760 | {return str().compare(__s);} | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 4761 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 4762 | int compare(const value_type* __s) const | 
|  | 4763 | {return str().compare(__s);} | 
|  | 4764 | }; | 
|  | 4765 |  | 
|  | 4766 | typedef sub_match<const char*> csub_match; | 
|  | 4767 | typedef sub_match<const wchar_t*> wcsub_match; | 
|  | 4768 | typedef sub_match<string::const_iterator> ssub_match; | 
|  | 4769 | typedef sub_match<wstring::const_iterator> wssub_match; | 
|  | 4770 |  | 
|  | 4771 | template <class _BiIter> | 
|  | 4772 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 4773 | bool | 
|  | 4774 | operator==(const sub_match<_BiIter>& __x, const sub_match<_BiIter>& __y) | 
|  | 4775 | { | 
|  | 4776 | return __x.compare(__y) == 0; | 
|  | 4777 | } | 
|  | 4778 |  | 
|  | 4779 | template <class _BiIter> | 
|  | 4780 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 4781 | bool | 
|  | 4782 | operator!=(const sub_match<_BiIter>& __x, const sub_match<_BiIter>& __y) | 
|  | 4783 | { | 
|  | 4784 | return !(__x == __y); | 
|  | 4785 | } | 
|  | 4786 |  | 
|  | 4787 | template <class _BiIter> | 
|  | 4788 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 4789 | bool | 
|  | 4790 | operator<(const sub_match<_BiIter>& __x, const sub_match<_BiIter>& __y) | 
|  | 4791 | { | 
|  | 4792 | return __x.compare(__y) < 0; | 
|  | 4793 | } | 
|  | 4794 |  | 
|  | 4795 | template <class _BiIter> | 
|  | 4796 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 4797 | bool | 
|  | 4798 | operator<=(const sub_match<_BiIter>& __x, const sub_match<_BiIter>& __y) | 
|  | 4799 | { | 
|  | 4800 | return !(__y < __x); | 
|  | 4801 | } | 
|  | 4802 |  | 
|  | 4803 | template <class _BiIter> | 
|  | 4804 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 4805 | bool | 
|  | 4806 | operator>=(const sub_match<_BiIter>& __x, const sub_match<_BiIter>& __y) | 
|  | 4807 | { | 
|  | 4808 | return !(__x < __y); | 
|  | 4809 | } | 
|  | 4810 |  | 
|  | 4811 | template <class _BiIter> | 
|  | 4812 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 4813 | bool | 
|  | 4814 | operator>(const sub_match<_BiIter>& __x, const sub_match<_BiIter>& __y) | 
|  | 4815 | { | 
|  | 4816 | return __y < __x; | 
|  | 4817 | } | 
|  | 4818 |  | 
|  | 4819 | template <class _BiIter, class _ST, class _SA> | 
|  | 4820 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 4821 | bool | 
|  | 4822 | operator==(const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __x, | 
|  | 4823 | const sub_match<_BiIter>& __y) | 
|  | 4824 | { | 
|  | 4825 | return __y.compare(__x.c_str()) == 0; | 
|  | 4826 | } | 
|  | 4827 |  | 
|  | 4828 | template <class _BiIter, class _ST, class _SA> | 
|  | 4829 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 4830 | bool | 
|  | 4831 | operator!=(const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __x, | 
|  | 4832 | const sub_match<_BiIter>& __y) | 
|  | 4833 | { | 
|  | 4834 | return !(__x == __y); | 
|  | 4835 | } | 
|  | 4836 |  | 
|  | 4837 | template <class _BiIter, class _ST, class _SA> | 
|  | 4838 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 4839 | bool | 
|  | 4840 | operator<(const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __x, | 
|  | 4841 | const sub_match<_BiIter>& __y) | 
|  | 4842 | { | 
|  | 4843 | return __y.compare(__x.c_str()) > 0; | 
|  | 4844 | } | 
|  | 4845 |  | 
|  | 4846 | template <class _BiIter, class _ST, class _SA> | 
|  | 4847 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 4848 | bool | 
|  | 4849 | operator>(const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __x, | 
|  | 4850 | const sub_match<_BiIter>& __y) | 
|  | 4851 | { | 
|  | 4852 | return __y < __x; | 
|  | 4853 | } | 
|  | 4854 |  | 
|  | 4855 | template <class _BiIter, class _ST, class _SA> | 
|  | 4856 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 4857 | bool operator>=(const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __x, | 
|  | 4858 | const sub_match<_BiIter>& __y) | 
|  | 4859 | { | 
|  | 4860 | return !(__x < __y); | 
|  | 4861 | } | 
|  | 4862 |  | 
|  | 4863 | template <class _BiIter, class _ST, class _SA> | 
|  | 4864 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 4865 | bool | 
|  | 4866 | operator<=(const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __x, | 
|  | 4867 | const sub_match<_BiIter>& __y) | 
|  | 4868 | { | 
|  | 4869 | return !(__y < __x); | 
|  | 4870 | } | 
|  | 4871 |  | 
|  | 4872 | template <class _BiIter, class _ST, class _SA> | 
|  | 4873 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 4874 | bool | 
|  | 4875 | operator==(const sub_match<_BiIter>& __x, | 
|  | 4876 | const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __y) | 
|  | 4877 | { | 
|  | 4878 | return __x.compare(__y.c_str()) == 0; | 
|  | 4879 | } | 
|  | 4880 |  | 
|  | 4881 | template <class _BiIter, class _ST, class _SA> | 
|  | 4882 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 4883 | bool | 
|  | 4884 | operator!=(const sub_match<_BiIter>& __x, | 
|  | 4885 | const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __y) | 
|  | 4886 | { | 
|  | 4887 | return !(__x == __y); | 
|  | 4888 | } | 
|  | 4889 |  | 
|  | 4890 | template <class _BiIter, class _ST, class _SA> | 
|  | 4891 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 4892 | bool | 
|  | 4893 | operator<(const sub_match<_BiIter>& __x, | 
|  | 4894 | const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __y) | 
|  | 4895 | { | 
|  | 4896 | return __x.compare(__y.c_str()) < 0; | 
|  | 4897 | } | 
|  | 4898 |  | 
|  | 4899 | template <class _BiIter, class _ST, class _SA> | 
|  | 4900 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 4901 | bool operator>(const sub_match<_BiIter>& __x, | 
|  | 4902 | const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __y) | 
|  | 4903 | { | 
|  | 4904 | return __y < __x; | 
|  | 4905 | } | 
|  | 4906 |  | 
|  | 4907 | template <class _BiIter, class _ST, class _SA> | 
|  | 4908 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 4909 | bool | 
|  | 4910 | operator>=(const sub_match<_BiIter>& __x, | 
|  | 4911 | const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __y) | 
|  | 4912 | { | 
|  | 4913 | return !(__x < __y); | 
|  | 4914 | } | 
|  | 4915 |  | 
|  | 4916 | template <class _BiIter, class _ST, class _SA> | 
|  | 4917 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 4918 | bool | 
|  | 4919 | operator<=(const sub_match<_BiIter>& __x, | 
|  | 4920 | const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __y) | 
|  | 4921 | { | 
|  | 4922 | return !(__y < __x); | 
|  | 4923 | } | 
|  | 4924 |  | 
|  | 4925 | template <class _BiIter> | 
|  | 4926 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 4927 | bool | 
|  | 4928 | operator==(typename iterator_traits<_BiIter>::value_type const* __x, | 
|  | 4929 | const sub_match<_BiIter>& __y) | 
|  | 4930 | { | 
|  | 4931 | return __y.compare(__x) == 0; | 
|  | 4932 | } | 
|  | 4933 |  | 
|  | 4934 | template <class _BiIter> | 
|  | 4935 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 4936 | bool | 
|  | 4937 | operator!=(typename iterator_traits<_BiIter>::value_type const* __x, | 
|  | 4938 | const sub_match<_BiIter>& __y) | 
|  | 4939 | { | 
|  | 4940 | return !(__x == __y); | 
|  | 4941 | } | 
|  | 4942 |  | 
|  | 4943 | template <class _BiIter> | 
|  | 4944 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 4945 | bool | 
|  | 4946 | operator<(typename iterator_traits<_BiIter>::value_type const* __x, | 
|  | 4947 | const sub_match<_BiIter>& __y) | 
|  | 4948 | { | 
|  | 4949 | return __y.compare(__x) > 0; | 
|  | 4950 | } | 
|  | 4951 |  | 
|  | 4952 | template <class _BiIter> | 
|  | 4953 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 4954 | bool | 
|  | 4955 | operator>(typename iterator_traits<_BiIter>::value_type const* __x, | 
|  | 4956 | const sub_match<_BiIter>& __y) | 
|  | 4957 | { | 
|  | 4958 | return __y < __x; | 
|  | 4959 | } | 
|  | 4960 |  | 
|  | 4961 | template <class _BiIter> | 
|  | 4962 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 4963 | bool | 
|  | 4964 | operator>=(typename iterator_traits<_BiIter>::value_type const* __x, | 
|  | 4965 | const sub_match<_BiIter>& __y) | 
|  | 4966 | { | 
|  | 4967 | return !(__x < __y); | 
|  | 4968 | } | 
|  | 4969 |  | 
|  | 4970 | template <class _BiIter> | 
|  | 4971 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 4972 | bool | 
|  | 4973 | operator<=(typename iterator_traits<_BiIter>::value_type const* __x, | 
|  | 4974 | const sub_match<_BiIter>& __y) | 
|  | 4975 | { | 
|  | 4976 | return !(__y < __x); | 
|  | 4977 | } | 
|  | 4978 |  | 
|  | 4979 | template <class _BiIter> | 
|  | 4980 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 4981 | bool | 
|  | 4982 | operator==(const sub_match<_BiIter>& __x, | 
|  | 4983 | typename iterator_traits<_BiIter>::value_type const* __y) | 
|  | 4984 | { | 
|  | 4985 | return __x.compare(__y) == 0; | 
|  | 4986 | } | 
|  | 4987 |  | 
|  | 4988 | template <class _BiIter> | 
|  | 4989 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 4990 | bool | 
|  | 4991 | operator!=(const sub_match<_BiIter>& __x, | 
|  | 4992 | typename iterator_traits<_BiIter>::value_type const* __y) | 
|  | 4993 | { | 
|  | 4994 | return !(__x == __y); | 
|  | 4995 | } | 
|  | 4996 |  | 
|  | 4997 | template <class _BiIter> | 
|  | 4998 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 4999 | bool | 
|  | 5000 | operator<(const sub_match<_BiIter>& __x, | 
|  | 5001 | typename iterator_traits<_BiIter>::value_type const* __y) | 
|  | 5002 | { | 
|  | 5003 | return __x.compare(__y) < 0; | 
|  | 5004 | } | 
|  | 5005 |  | 
|  | 5006 | template <class _BiIter> | 
|  | 5007 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 5008 | bool | 
|  | 5009 | operator>(const sub_match<_BiIter>& __x, | 
|  | 5010 | typename iterator_traits<_BiIter>::value_type const* __y) | 
|  | 5011 | { | 
|  | 5012 | return __y < __x; | 
|  | 5013 | } | 
|  | 5014 |  | 
|  | 5015 | template <class _BiIter> | 
|  | 5016 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 5017 | bool | 
|  | 5018 | operator>=(const sub_match<_BiIter>& __x, | 
|  | 5019 | typename iterator_traits<_BiIter>::value_type const* __y) | 
|  | 5020 | { | 
|  | 5021 | return !(__x < __y); | 
|  | 5022 | } | 
|  | 5023 |  | 
|  | 5024 | template <class _BiIter> | 
|  | 5025 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 5026 | bool | 
|  | 5027 | operator<=(const sub_match<_BiIter>& __x, | 
|  | 5028 | typename iterator_traits<_BiIter>::value_type const* __y) | 
|  | 5029 | { | 
|  | 5030 | return !(__y < __x); | 
|  | 5031 | } | 
|  | 5032 |  | 
|  | 5033 | template <class _BiIter> | 
|  | 5034 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 5035 | bool | 
|  | 5036 | operator==(typename iterator_traits<_BiIter>::value_type const& __x, | 
|  | 5037 | const sub_match<_BiIter>& __y) | 
|  | 5038 | { | 
|  | 5039 | typedef basic_string<typename iterator_traits<_BiIter>::value_type> string_type; | 
|  | 5040 | return __y.compare(string_type(1, __x)) == 0; | 
|  | 5041 | } | 
|  | 5042 |  | 
|  | 5043 | template <class _BiIter> | 
|  | 5044 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 5045 | bool | 
|  | 5046 | operator!=(typename iterator_traits<_BiIter>::value_type const& __x, | 
|  | 5047 | const sub_match<_BiIter>& __y) | 
|  | 5048 | { | 
|  | 5049 | return !(__x == __y); | 
|  | 5050 | } | 
|  | 5051 |  | 
|  | 5052 | template <class _BiIter> | 
|  | 5053 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 5054 | bool | 
|  | 5055 | operator<(typename iterator_traits<_BiIter>::value_type const& __x, | 
|  | 5056 | const sub_match<_BiIter>& __y) | 
|  | 5057 | { | 
|  | 5058 | typedef basic_string<typename iterator_traits<_BiIter>::value_type> string_type; | 
|  | 5059 | return __y.compare(string_type(1, __x)) > 0; | 
|  | 5060 | } | 
|  | 5061 |  | 
|  | 5062 | template <class _BiIter> | 
|  | 5063 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 5064 | bool | 
|  | 5065 | operator>(typename iterator_traits<_BiIter>::value_type const& __x, | 
|  | 5066 | const sub_match<_BiIter>& __y) | 
|  | 5067 | { | 
|  | 5068 | return __y < __x; | 
|  | 5069 | } | 
|  | 5070 |  | 
|  | 5071 | template <class _BiIter> | 
|  | 5072 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 5073 | bool | 
|  | 5074 | operator>=(typename iterator_traits<_BiIter>::value_type const& __x, | 
|  | 5075 | const sub_match<_BiIter>& __y) | 
|  | 5076 | { | 
|  | 5077 | return !(__x < __y); | 
|  | 5078 | } | 
|  | 5079 |  | 
|  | 5080 | template <class _BiIter> | 
|  | 5081 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 5082 | bool | 
|  | 5083 | operator<=(typename iterator_traits<_BiIter>::value_type const& __x, | 
|  | 5084 | const sub_match<_BiIter>& __y) | 
|  | 5085 | { | 
|  | 5086 | return !(__y < __x); | 
|  | 5087 | } | 
|  | 5088 |  | 
|  | 5089 | template <class _BiIter> | 
|  | 5090 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 5091 | bool | 
|  | 5092 | operator==(const sub_match<_BiIter>& __x, | 
|  | 5093 | typename iterator_traits<_BiIter>::value_type const& __y) | 
|  | 5094 | { | 
|  | 5095 | typedef basic_string<typename iterator_traits<_BiIter>::value_type> string_type; | 
|  | 5096 | return __x.compare(string_type(1, __y)) == 0; | 
|  | 5097 | } | 
|  | 5098 |  | 
|  | 5099 | template <class _BiIter> | 
|  | 5100 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 5101 | bool | 
|  | 5102 | operator!=(const sub_match<_BiIter>& __x, | 
|  | 5103 | typename iterator_traits<_BiIter>::value_type const& __y) | 
|  | 5104 | { | 
|  | 5105 | return !(__x == __y); | 
|  | 5106 | } | 
|  | 5107 |  | 
|  | 5108 | template <class _BiIter> | 
|  | 5109 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 5110 | bool | 
|  | 5111 | operator<(const sub_match<_BiIter>& __x, | 
|  | 5112 | typename iterator_traits<_BiIter>::value_type const& __y) | 
|  | 5113 | { | 
|  | 5114 | typedef basic_string<typename iterator_traits<_BiIter>::value_type> string_type; | 
|  | 5115 | return __x.compare(string_type(1, __y)) < 0; | 
|  | 5116 | } | 
|  | 5117 |  | 
|  | 5118 | template <class _BiIter> | 
|  | 5119 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 5120 | bool | 
|  | 5121 | operator>(const sub_match<_BiIter>& __x, | 
|  | 5122 | typename iterator_traits<_BiIter>::value_type const& __y) | 
|  | 5123 | { | 
|  | 5124 | return __y < __x; | 
|  | 5125 | } | 
|  | 5126 |  | 
|  | 5127 | template <class _BiIter> | 
|  | 5128 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 5129 | bool | 
|  | 5130 | operator>=(const sub_match<_BiIter>& __x, | 
|  | 5131 | typename iterator_traits<_BiIter>::value_type const& __y) | 
|  | 5132 | { | 
|  | 5133 | return !(__x < __y); | 
|  | 5134 | } | 
|  | 5135 |  | 
|  | 5136 | template <class _BiIter> | 
|  | 5137 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 5138 | bool | 
|  | 5139 | operator<=(const sub_match<_BiIter>& __x, | 
|  | 5140 | typename iterator_traits<_BiIter>::value_type const& __y) | 
|  | 5141 | { | 
|  | 5142 | return !(__y < __x); | 
|  | 5143 | } | 
|  | 5144 |  | 
|  | 5145 | template <class _CharT, class _ST, class _BiIter> | 
|  | 5146 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 5147 | basic_ostream<_CharT, _ST>& | 
|  | 5148 | operator<<(basic_ostream<_CharT, _ST>& __os, const sub_match<_BiIter>& __m) | 
|  | 5149 | { | 
|  | 5150 | return __os << __m.str(); | 
|  | 5151 | } | 
|  | 5152 |  | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 5153 | template <class _BidirectionalIterator, class _Allocator> | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 5154 | class _LIBCPP_VISIBLE match_results | 
| Howard Hinnant | 7e9d84b | 2010-06-30 00:21:42 | [diff] [blame] | 5155 | { | 
|  | 5156 | public: | 
|  | 5157 | typedef _Allocator allocator_type; | 
|  | 5158 | typedef sub_match<_BidirectionalIterator> value_type; | 
|  | 5159 | private: | 
|  | 5160 | typedef vector<value_type, allocator_type> __container_type; | 
|  | 5161 |  | 
|  | 5162 | __container_type __matches_; | 
|  | 5163 | value_type __unmatched_; | 
|  | 5164 | value_type __prefix_; | 
|  | 5165 | value_type __suffix_; | 
| Howard Hinnant | 31aaf55 | 2010-12-08 21:07:55 | [diff] [blame] | 5166 | bool __ready_; | 
| Howard Hinnant | 7e9d84b | 2010-06-30 00:21:42 | [diff] [blame] | 5167 | public: | 
| Howard Hinnant | a712c72 | 2010-08-16 20:21:16 | [diff] [blame] | 5168 | _BidirectionalIterator __position_start_; | 
| Howard Hinnant | 7e9d84b | 2010-06-30 00:21:42 | [diff] [blame] | 5169 | typedef const value_type& const_reference; | 
|  | 5170 | typedef const_reference reference; | 
|  | 5171 | typedef typename __container_type::const_iterator const_iterator; | 
|  | 5172 | typedef const_iterator iterator; | 
|  | 5173 | typedef typename iterator_traits<_BidirectionalIterator>::difference_type difference_type; | 
|  | 5174 | typedef typename allocator_traits<allocator_type>::size_type size_type; | 
|  | 5175 | typedef typename iterator_traits<_BidirectionalIterator>::value_type char_type; | 
|  | 5176 | typedef basic_string<char_type> string_type; | 
|  | 5177 |  | 
|  | 5178 | // construct/copy/destroy: | 
|  | 5179 | explicit match_results(const allocator_type& __a = allocator_type()); | 
|  | 5180 | // match_results(const match_results&) = default; | 
|  | 5181 | // match_results& operator=(const match_results&) = default; | 
| Howard Hinnant | 7e9d84b | 2010-06-30 00:21:42 | [diff] [blame] | 5182 | // match_results(match_results&& __m) = default; | 
|  | 5183 | // match_results& operator=(match_results&& __m) = default; | 
| Howard Hinnant | 7e9d84b | 2010-06-30 00:21:42 | [diff] [blame] | 5184 | // ~match_results() = default; | 
|  | 5185 |  | 
| Howard Hinnant | 31aaf55 | 2010-12-08 21:07:55 | [diff] [blame] | 5186 | _LIBCPP_INLINE_VISIBILITY | 
|  | 5187 | bool ready() const {return __ready_;} | 
|  | 5188 |  | 
| Howard Hinnant | 7e9d84b | 2010-06-30 00:21:42 | [diff] [blame] | 5189 | // size: | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 5190 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 7e9d84b | 2010-06-30 00:21:42 | [diff] [blame] | 5191 | size_type size() const {return __matches_.size();} | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 5192 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 7e9d84b | 2010-06-30 00:21:42 | [diff] [blame] | 5193 | size_type max_size() const {return __matches_.max_size();} | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 5194 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 7e9d84b | 2010-06-30 00:21:42 | [diff] [blame] | 5195 | bool empty() const {return size() == 0;} | 
|  | 5196 |  | 
|  | 5197 | // element access: | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 5198 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 7e9d84b | 2010-06-30 00:21:42 | [diff] [blame] | 5199 | difference_type length(size_type __sub = 0) const | 
|  | 5200 | {return (*this)[__sub].length();} | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 5201 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 7e9d84b | 2010-06-30 00:21:42 | [diff] [blame] | 5202 | difference_type position(size_type __sub = 0) const | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 5203 | {return _VSTD::distance(__position_start_, (*this)[__sub].first);} | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 5204 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 7e9d84b | 2010-06-30 00:21:42 | [diff] [blame] | 5205 | string_type str(size_type __sub = 0) const | 
|  | 5206 | {return (*this)[__sub].str();} | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 5207 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 7e9d84b | 2010-06-30 00:21:42 | [diff] [blame] | 5208 | const_reference operator[](size_type __n) const | 
|  | 5209 | {return __n < __matches_.size() ? __matches_[__n] : __unmatched_;} | 
|  | 5210 |  | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 5211 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 7e9d84b | 2010-06-30 00:21:42 | [diff] [blame] | 5212 | const_reference prefix() const {return __prefix_;} | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 5213 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 7e9d84b | 2010-06-30 00:21:42 | [diff] [blame] | 5214 | const_reference suffix() const {return __suffix_;} | 
|  | 5215 |  | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 5216 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | c6fe8ca | 2011-10-08 14:36:16 | [diff] [blame] | 5217 | const_iterator begin() const {return empty() ? __matches_.end() : __matches_.begin();} | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 5218 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 7e9d84b | 2010-06-30 00:21:42 | [diff] [blame] | 5219 | const_iterator end() const {return __matches_.end();} | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 5220 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | c6fe8ca | 2011-10-08 14:36:16 | [diff] [blame] | 5221 | const_iterator cbegin() const {return empty() ? __matches_.end() : __matches_.begin();} | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 5222 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 7e9d84b | 2010-06-30 00:21:42 | [diff] [blame] | 5223 | const_iterator cend() const {return __matches_.end();} | 
|  | 5224 |  | 
|  | 5225 | // format: | 
|  | 5226 | template <class _OutputIter> | 
|  | 5227 | _OutputIter | 
|  | 5228 | format(_OutputIter __out, const char_type* __fmt_first, | 
|  | 5229 | const char_type* __fmt_last, | 
|  | 5230 | regex_constants::match_flag_type __flags = regex_constants::format_default) const; | 
|  | 5231 | template <class _OutputIter, class _ST, class _SA> | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 5232 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 7e9d84b | 2010-06-30 00:21:42 | [diff] [blame] | 5233 | _OutputIter | 
|  | 5234 | format(_OutputIter __out, const basic_string<char_type, _ST, _SA>& __fmt, | 
| Howard Hinnant | 27405f9 | 2010-08-14 18:14:02 | [diff] [blame] | 5235 | regex_constants::match_flag_type __flags = regex_constants::format_default) const | 
|  | 5236 | {return format(__out, __fmt.data(), __fmt.data() + __fmt.size(), __flags);} | 
| Howard Hinnant | 7e9d84b | 2010-06-30 00:21:42 | [diff] [blame] | 5237 | template <class _ST, class _SA> | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 5238 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 7e9d84b | 2010-06-30 00:21:42 | [diff] [blame] | 5239 | basic_string<char_type, _ST, _SA> | 
|  | 5240 | format(const basic_string<char_type, _ST, _SA>& __fmt, | 
| Howard Hinnant | 27405f9 | 2010-08-14 18:14:02 | [diff] [blame] | 5241 | regex_constants::match_flag_type __flags = regex_constants::format_default) const | 
|  | 5242 | { | 
|  | 5243 | basic_string<char_type, _ST, _SA> __r; | 
|  | 5244 | format(back_inserter(__r), __fmt.data(), __fmt.data() + __fmt.size(), | 
|  | 5245 | __flags); | 
|  | 5246 | return __r; | 
|  | 5247 | } | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 5248 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 7e9d84b | 2010-06-30 00:21:42 | [diff] [blame] | 5249 | string_type | 
|  | 5250 | format(const char_type* __fmt, | 
| Howard Hinnant | 27405f9 | 2010-08-14 18:14:02 | [diff] [blame] | 5251 | regex_constants::match_flag_type __flags = regex_constants::format_default) const | 
|  | 5252 | { | 
|  | 5253 | string_type __r; | 
|  | 5254 | format(back_inserter(__r), __fmt, | 
|  | 5255 | __fmt + char_traits<char_type>::length(__fmt), __flags); | 
|  | 5256 | return __r; | 
|  | 5257 | } | 
| Howard Hinnant | 7e9d84b | 2010-06-30 00:21:42 | [diff] [blame] | 5258 |  | 
|  | 5259 | // allocator: | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 5260 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 7e9d84b | 2010-06-30 00:21:42 | [diff] [blame] | 5261 | allocator_type get_allocator() const {return __matches_.get_allocator();} | 
|  | 5262 |  | 
|  | 5263 | // swap: | 
|  | 5264 | void swap(match_results& __m); | 
|  | 5265 |  | 
| Howard Hinnant | 9996844 | 2011-11-29 18:15:50 | [diff] [blame] | 5266 | template <class _Bp, class _Ap> | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 5267 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 22ce0b4 | 2010-07-14 21:14:52 | [diff] [blame] | 5268 | void __assign(_BidirectionalIterator __f, _BidirectionalIterator __l, | 
| Howard Hinnant | 9996844 | 2011-11-29 18:15:50 | [diff] [blame] | 5269 | const match_results<_Bp, _Ap>& __m, bool __no_update_pos) | 
| Howard Hinnant | 22ce0b4 | 2010-07-14 21:14:52 | [diff] [blame] | 5270 | { | 
| Howard Hinnant | 9996844 | 2011-11-29 18:15:50 | [diff] [blame] | 5271 | _Bp __mf = __m.prefix().first; | 
| Howard Hinnant | 22ce0b4 | 2010-07-14 21:14:52 | [diff] [blame] | 5272 | __matches_.resize(__m.size()); | 
|  | 5273 | for (size_type __i = 0; __i < __matches_.size(); ++__i) | 
|  | 5274 | { | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 5275 | __matches_[__i].first = _VSTD::next(__f, _VSTD::distance(__mf, __m[__i].first)); | 
|  | 5276 | __matches_[__i].second = _VSTD::next(__f, _VSTD::distance(__mf, __m[__i].second)); | 
| Howard Hinnant | 22ce0b4 | 2010-07-14 21:14:52 | [diff] [blame] | 5277 | __matches_[__i].matched = __m[__i].matched; | 
|  | 5278 | } | 
|  | 5279 | __unmatched_.first = __l; | 
|  | 5280 | __unmatched_.second = __l; | 
|  | 5281 | __unmatched_.matched = false; | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 5282 | __prefix_.first = _VSTD::next(__f, _VSTD::distance(__mf, __m.prefix().first)); | 
|  | 5283 | __prefix_.second = _VSTD::next(__f, _VSTD::distance(__mf, __m.prefix().second)); | 
| Howard Hinnant | 22ce0b4 | 2010-07-14 21:14:52 | [diff] [blame] | 5284 | __prefix_.matched = __m.prefix().matched; | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 5285 | __suffix_.first = _VSTD::next(__f, _VSTD::distance(__mf, __m.suffix().first)); | 
|  | 5286 | __suffix_.second = _VSTD::next(__f, _VSTD::distance(__mf, __m.suffix().second)); | 
| Howard Hinnant | 22ce0b4 | 2010-07-14 21:14:52 | [diff] [blame] | 5287 | __suffix_.matched = __m.suffix().matched; | 
| Howard Hinnant | a712c72 | 2010-08-16 20:21:16 | [diff] [blame] | 5288 | if (!__no_update_pos) | 
|  | 5289 | __position_start_ = __prefix_.first; | 
| Howard Hinnant | 31aaf55 | 2010-12-08 21:07:55 | [diff] [blame] | 5290 | __ready_ = __m.ready(); | 
| Howard Hinnant | 22ce0b4 | 2010-07-14 21:14:52 | [diff] [blame] | 5291 | } | 
|  | 5292 |  | 
| Howard Hinnant | 9b80f2b | 2010-06-30 17:22:19 | [diff] [blame] | 5293 | private: | 
|  | 5294 | void __init(unsigned __s, | 
| Howard Hinnant | a712c72 | 2010-08-16 20:21:16 | [diff] [blame] | 5295 | _BidirectionalIterator __f, _BidirectionalIterator __l, | 
|  | 5296 | bool __no_update_pos = false); | 
| Howard Hinnant | 9b80f2b | 2010-06-30 17:22:19 | [diff] [blame] | 5297 |  | 
|  | 5298 | template <class, class> friend class basic_regex; | 
|  | 5299 |  | 
| Howard Hinnant | 9996844 | 2011-11-29 18:15:50 | [diff] [blame] | 5300 | template <class _Bp, class _Ap, class _Cp, class _Tp> | 
| Howard Hinnant | 7e9d84b | 2010-06-30 00:21:42 | [diff] [blame] | 5301 | friend | 
|  | 5302 | bool | 
| Howard Hinnant | 9996844 | 2011-11-29 18:15:50 | [diff] [blame] | 5303 | regex_match(_Bp, _Bp, match_results<_Bp, _Ap>&, const basic_regex<_Cp, _Tp>&, | 
| Howard Hinnant | 7e9d84b | 2010-06-30 00:21:42 | [diff] [blame] | 5304 | regex_constants::match_flag_type); | 
| Howard Hinnant | e9de5ff | 2010-07-27 22:20:32 | [diff] [blame] | 5305 |  | 
| Howard Hinnant | 9996844 | 2011-11-29 18:15:50 | [diff] [blame] | 5306 | template <class _Bp, class _Ap> | 
| Howard Hinnant | 27405f9 | 2010-08-14 18:14:02 | [diff] [blame] | 5307 | friend | 
|  | 5308 | bool | 
| Howard Hinnant | 9996844 | 2011-11-29 18:15:50 | [diff] [blame] | 5309 | operator==(const match_results<_Bp, _Ap>&, const match_results<_Bp, _Ap>&); | 
| Howard Hinnant | 27405f9 | 2010-08-14 18:14:02 | [diff] [blame] | 5310 |  | 
| Howard Hinnant | e9de5ff | 2010-07-27 22:20:32 | [diff] [blame] | 5311 | template <class, class> friend class __lookahead; | 
| Howard Hinnant | 7e9d84b | 2010-06-30 00:21:42 | [diff] [blame] | 5312 | }; | 
|  | 5313 |  | 
|  | 5314 | template <class _BidirectionalIterator, class _Allocator> | 
|  | 5315 | match_results<_BidirectionalIterator, _Allocator>::match_results( | 
|  | 5316 | const allocator_type& __a) | 
|  | 5317 | : __matches_(__a), | 
|  | 5318 | __unmatched_(), | 
|  | 5319 | __prefix_(), | 
| Howard Hinnant | a712c72 | 2010-08-16 20:21:16 | [diff] [blame] | 5320 | __suffix_(), | 
| Howard Hinnant | 31aaf55 | 2010-12-08 21:07:55 | [diff] [blame] | 5321 | __position_start_(), | 
|  | 5322 | __ready_(false) | 
| Howard Hinnant | 7e9d84b | 2010-06-30 00:21:42 | [diff] [blame] | 5323 | { | 
|  | 5324 | } | 
|  | 5325 |  | 
| Howard Hinnant | 9b80f2b | 2010-06-30 17:22:19 | [diff] [blame] | 5326 | template <class _BidirectionalIterator, class _Allocator> | 
|  | 5327 | void | 
|  | 5328 | match_results<_BidirectionalIterator, _Allocator>::__init(unsigned __s, | 
| Howard Hinnant | a712c72 | 2010-08-16 20:21:16 | [diff] [blame] | 5329 | _BidirectionalIterator __f, _BidirectionalIterator __l, | 
|  | 5330 | bool __no_update_pos) | 
| Howard Hinnant | 9b80f2b | 2010-06-30 17:22:19 | [diff] [blame] | 5331 | { | 
| Howard Hinnant | 9b80f2b | 2010-06-30 17:22:19 | [diff] [blame] | 5332 | __unmatched_.first = __l; | 
|  | 5333 | __unmatched_.second = __l; | 
|  | 5334 | __unmatched_.matched = false; | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 5335 | __matches_.assign(__s, __unmatched_); | 
| Howard Hinnant | 9b80f2b | 2010-06-30 17:22:19 | [diff] [blame] | 5336 | __prefix_.first = __f; | 
|  | 5337 | __prefix_.second = __f; | 
|  | 5338 | __prefix_.matched = false; | 
| Howard Hinnant | e77aa5e | 2010-07-08 17:43:58 | [diff] [blame] | 5339 | __suffix_ = __unmatched_; | 
| Howard Hinnant | a712c72 | 2010-08-16 20:21:16 | [diff] [blame] | 5340 | if (!__no_update_pos) | 
|  | 5341 | __position_start_ = __prefix_.first; | 
| Howard Hinnant | 31aaf55 | 2010-12-08 21:07:55 | [diff] [blame] | 5342 | __ready_ = true; | 
| Howard Hinnant | 9b80f2b | 2010-06-30 17:22:19 | [diff] [blame] | 5343 | } | 
|  | 5344 |  | 
| Howard Hinnant | 27405f9 | 2010-08-14 18:14:02 | [diff] [blame] | 5345 | template <class _BidirectionalIterator, class _Allocator> | 
|  | 5346 | template <class _OutputIter> | 
|  | 5347 | _OutputIter | 
|  | 5348 | match_results<_BidirectionalIterator, _Allocator>::format(_OutputIter __out, | 
|  | 5349 | const char_type* __fmt_first, const char_type* __fmt_last, | 
|  | 5350 | regex_constants::match_flag_type __flags) const | 
|  | 5351 | { | 
|  | 5352 | if (__flags & regex_constants::format_sed) | 
|  | 5353 | { | 
|  | 5354 | for (; __fmt_first != __fmt_last; ++__fmt_first) | 
|  | 5355 | { | 
|  | 5356 | if (*__fmt_first == '&') | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 5357 | __out = _VSTD::copy(__matches_[0].first, __matches_[0].second, | 
| Howard Hinnant | 27405f9 | 2010-08-14 18:14:02 | [diff] [blame] | 5358 | __out); | 
|  | 5359 | else if (*__fmt_first == '\\' && __fmt_first + 1 != __fmt_last) | 
|  | 5360 | { | 
|  | 5361 | ++__fmt_first; | 
|  | 5362 | if ('0' <= *__fmt_first && *__fmt_first <= '9') | 
|  | 5363 | { | 
|  | 5364 | size_t __i = *__fmt_first - '0'; | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 5365 | __out = _VSTD::copy(__matches_[__i].first, | 
| Howard Hinnant | 27405f9 | 2010-08-14 18:14:02 | [diff] [blame] | 5366 | __matches_[__i].second, __out); | 
|  | 5367 | } | 
|  | 5368 | else | 
|  | 5369 | { | 
|  | 5370 | *__out = *__fmt_first; | 
|  | 5371 | ++__out; | 
|  | 5372 | } | 
|  | 5373 | } | 
|  | 5374 | else | 
|  | 5375 | { | 
|  | 5376 | *__out = *__fmt_first; | 
|  | 5377 | ++__out; | 
|  | 5378 | } | 
|  | 5379 | } | 
|  | 5380 | } | 
|  | 5381 | else | 
|  | 5382 | { | 
|  | 5383 | for (; __fmt_first != __fmt_last; ++__fmt_first) | 
|  | 5384 | { | 
|  | 5385 | if (*__fmt_first == '$' && __fmt_first + 1 != __fmt_last) | 
|  | 5386 | { | 
|  | 5387 | switch (__fmt_first[1]) | 
|  | 5388 | { | 
|  | 5389 | case '$': | 
|  | 5390 | *__out = *++__fmt_first; | 
|  | 5391 | ++__out; | 
|  | 5392 | break; | 
|  | 5393 | case '&': | 
|  | 5394 | ++__fmt_first; | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 5395 | __out = _VSTD::copy(__matches_[0].first, __matches_[0].second, | 
| Howard Hinnant | 27405f9 | 2010-08-14 18:14:02 | [diff] [blame] | 5396 | __out); | 
|  | 5397 | break; | 
|  | 5398 | case '`': | 
|  | 5399 | ++__fmt_first; | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 5400 | __out = _VSTD::copy(__prefix_.first, __prefix_.second, __out); | 
| Howard Hinnant | 27405f9 | 2010-08-14 18:14:02 | [diff] [blame] | 5401 | break; | 
|  | 5402 | case '\'': | 
|  | 5403 | ++__fmt_first; | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 5404 | __out = _VSTD::copy(__suffix_.first, __suffix_.second, __out); | 
| Howard Hinnant | 27405f9 | 2010-08-14 18:14:02 | [diff] [blame] | 5405 | break; | 
|  | 5406 | default: | 
|  | 5407 | if ('0' <= __fmt_first[1] && __fmt_first[1] <= '9') | 
|  | 5408 | { | 
|  | 5409 | ++__fmt_first; | 
|  | 5410 | size_t __i = *__fmt_first - '0'; | 
|  | 5411 | if (__fmt_first + 1 != __fmt_last && | 
|  | 5412 | '0' <= __fmt_first[1] && __fmt_first[1] <= '9') | 
|  | 5413 | { | 
|  | 5414 | ++__fmt_first; | 
|  | 5415 | __i = 10 * __i + *__fmt_first - '0'; | 
|  | 5416 | } | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 5417 | __out = _VSTD::copy(__matches_[__i].first, | 
| Howard Hinnant | 27405f9 | 2010-08-14 18:14:02 | [diff] [blame] | 5418 | __matches_[__i].second, __out); | 
|  | 5419 | } | 
|  | 5420 | else | 
|  | 5421 | { | 
|  | 5422 | *__out = *__fmt_first; | 
|  | 5423 | ++__out; | 
|  | 5424 | } | 
|  | 5425 | break; | 
|  | 5426 | } | 
|  | 5427 | } | 
|  | 5428 | else | 
|  | 5429 | { | 
|  | 5430 | *__out = *__fmt_first; | 
|  | 5431 | ++__out; | 
|  | 5432 | } | 
|  | 5433 | } | 
|  | 5434 | } | 
|  | 5435 | return __out; | 
|  | 5436 | } | 
|  | 5437 |  | 
|  | 5438 | template <class _BidirectionalIterator, class _Allocator> | 
|  | 5439 | void | 
|  | 5440 | match_results<_BidirectionalIterator, _Allocator>::swap(match_results& __m) | 
|  | 5441 | { | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 5442 | using _VSTD::swap; | 
| Howard Hinnant | 27405f9 | 2010-08-14 18:14:02 | [diff] [blame] | 5443 | swap(__matches_, __m.__matches_); | 
|  | 5444 | swap(__unmatched_, __m.__unmatched_); | 
|  | 5445 | swap(__prefix_, __m.__prefix_); | 
|  | 5446 | swap(__suffix_, __m.__suffix_); | 
| Howard Hinnant | a712c72 | 2010-08-16 20:21:16 | [diff] [blame] | 5447 | swap(__position_start_, __m.__position_start_); | 
| Howard Hinnant | 31aaf55 | 2010-12-08 21:07:55 | [diff] [blame] | 5448 | swap(__ready_, __m.__ready_); | 
| Howard Hinnant | 27405f9 | 2010-08-14 18:14:02 | [diff] [blame] | 5449 | } | 
|  | 5450 |  | 
| Howard Hinnant | 7e9d84b | 2010-06-30 00:21:42 | [diff] [blame] | 5451 | typedef match_results<const char*> cmatch; | 
|  | 5452 | typedef match_results<const wchar_t*> wcmatch; | 
|  | 5453 | typedef match_results<string::const_iterator> smatch; | 
|  | 5454 | typedef match_results<wstring::const_iterator> wsmatch; | 
|  | 5455 |  | 
|  | 5456 | template <class _BidirectionalIterator, class _Allocator> | 
| Howard Hinnant | 27405f9 | 2010-08-14 18:14:02 | [diff] [blame] | 5457 | bool | 
|  | 5458 | operator==(const match_results<_BidirectionalIterator, _Allocator>& __x, | 
|  | 5459 | const match_results<_BidirectionalIterator, _Allocator>& __y) | 
|  | 5460 | { | 
| Howard Hinnant | 31aaf55 | 2010-12-08 21:07:55 | [diff] [blame] | 5461 | if (__x.__ready_ != __y.__ready_) | 
|  | 5462 | return false; | 
|  | 5463 | if (!__x.__ready_) | 
|  | 5464 | return true; | 
| Howard Hinnant | 27405f9 | 2010-08-14 18:14:02 | [diff] [blame] | 5465 | return __x.__matches_ == __y.__matches_ && | 
|  | 5466 | __x.__prefix_ == __y.__prefix_ && | 
| Howard Hinnant | 31aaf55 | 2010-12-08 21:07:55 | [diff] [blame] | 5467 | __x.__suffix_ == __y.__suffix_; | 
| Howard Hinnant | 27405f9 | 2010-08-14 18:14:02 | [diff] [blame] | 5468 | } | 
| Howard Hinnant | 7e9d84b | 2010-06-30 00:21:42 | [diff] [blame] | 5469 |  | 
|  | 5470 | template <class _BidirectionalIterator, class _Allocator> | 
| Howard Hinnant | 27405f9 | 2010-08-14 18:14:02 | [diff] [blame] | 5471 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 5472 | bool | 
|  | 5473 | operator!=(const match_results<_BidirectionalIterator, _Allocator>& __x, | 
|  | 5474 | const match_results<_BidirectionalIterator, _Allocator>& __y) | 
|  | 5475 | { | 
|  | 5476 | return !(__x == __y); | 
|  | 5477 | } | 
| Howard Hinnant | 7e9d84b | 2010-06-30 00:21:42 | [diff] [blame] | 5478 |  | 
|  | 5479 | template <class _BidirectionalIterator, class _Allocator> | 
| Howard Hinnant | 27405f9 | 2010-08-14 18:14:02 | [diff] [blame] | 5480 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 5481 | void | 
|  | 5482 | swap(match_results<_BidirectionalIterator, _Allocator>& __x, | 
|  | 5483 | match_results<_BidirectionalIterator, _Allocator>& __y) | 
|  | 5484 | { | 
|  | 5485 | __x.swap(__y); | 
|  | 5486 | } | 
| Howard Hinnant | 7e9d84b | 2010-06-30 00:21:42 | [diff] [blame] | 5487 |  | 
|  | 5488 | // regex_search | 
|  | 5489 |  | 
| Howard Hinnant | 9b80f2b | 2010-06-30 17:22:19 | [diff] [blame] | 5490 | template <class _CharT, class _Traits> | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 5491 | template <class _Allocator> | 
| Howard Hinnant | 9b80f2b | 2010-06-30 17:22:19 | [diff] [blame] | 5492 | bool | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 5493 | basic_regex<_CharT, _Traits>::__match_at_start_ecma( | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 5494 | const _CharT* __first, const _CharT* __last, | 
|  | 5495 | match_results<const _CharT*, _Allocator>& __m, | 
| Howard Hinnant | 41fb6e1 | 2011-03-26 20:02:27 | [diff] [blame] | 5496 | regex_constants::match_flag_type __flags, bool __at_first) const | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 5497 | { | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 5498 | vector<__state> __states; | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 5499 | __node* __st = __start_.get(); | 
|  | 5500 | if (__st) | 
|  | 5501 | { | 
|  | 5502 | __states.push_back(__state()); | 
|  | 5503 | __states.back().__do_ = 0; | 
|  | 5504 | __states.back().__first_ = __first; | 
|  | 5505 | __states.back().__current_ = __first; | 
|  | 5506 | __states.back().__last_ = __last; | 
|  | 5507 | __states.back().__sub_matches_.resize(mark_count()); | 
|  | 5508 | __states.back().__loop_data_.resize(__loop_count()); | 
|  | 5509 | __states.back().__node_ = __st; | 
|  | 5510 | __states.back().__flags_ = __flags; | 
| Howard Hinnant | 41fb6e1 | 2011-03-26 20:02:27 | [diff] [blame] | 5511 | __states.back().__at_first_ = __at_first; | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 5512 | do | 
|  | 5513 | { | 
|  | 5514 | __state& __s = __states.back(); | 
|  | 5515 | if (__s.__node_) | 
|  | 5516 | __s.__node_->__exec(__s); | 
|  | 5517 | switch (__s.__do_) | 
|  | 5518 | { | 
|  | 5519 | case __state::__end_state: | 
|  | 5520 | __m.__matches_[0].first = __first; | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 5521 | __m.__matches_[0].second = _VSTD::next(__first, __s.__current_ - __first); | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 5522 | __m.__matches_[0].matched = true; | 
|  | 5523 | for (unsigned __i = 0; __i < __s.__sub_matches_.size(); ++__i) | 
|  | 5524 | __m.__matches_[__i+1] = __s.__sub_matches_[__i]; | 
|  | 5525 | return true; | 
|  | 5526 | case __state::__accept_and_consume: | 
|  | 5527 | case __state::__repeat: | 
|  | 5528 | case __state::__accept_but_not_consume: | 
|  | 5529 | break; | 
|  | 5530 | case __state::__split: | 
|  | 5531 | { | 
|  | 5532 | __state __snext = __s; | 
|  | 5533 | __s.__node_->__exec_split(true, __s); | 
|  | 5534 | __snext.__node_->__exec_split(false, __snext); | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 5535 | __states.push_back(_VSTD::move(__snext)); | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 5536 | } | 
|  | 5537 | break; | 
|  | 5538 | case __state::__reject: | 
|  | 5539 | __states.pop_back(); | 
|  | 5540 | break; | 
|  | 5541 | default: | 
| Howard Hinnant | d444470 | 2010-08-11 17:04:31 | [diff] [blame] | 5542 | #ifndef _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | ad2a7ab | 2010-07-27 17:24:17 | [diff] [blame] | 5543 | throw regex_error(regex_constants::__re_err_unknown); | 
| Howard Hinnant | d444470 | 2010-08-11 17:04:31 | [diff] [blame] | 5544 | #endif | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 5545 | break; | 
| Howard Hinnant | d444470 | 2010-08-11 17:04:31 | [diff] [blame] | 5546 |  | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 5547 | } | 
|  | 5548 | } while (!__states.empty()); | 
|  | 5549 | } | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 5550 | return false; | 
|  | 5551 | } | 
|  | 5552 |  | 
|  | 5553 | template <class _CharT, class _Traits> | 
| Howard Hinnant | 22ce0b4 | 2010-07-14 21:14:52 | [diff] [blame] | 5554 | template <class _Allocator> | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 5555 | bool | 
|  | 5556 | basic_regex<_CharT, _Traits>::__match_at_start_posix_nosubs( | 
|  | 5557 | const _CharT* __first, const _CharT* __last, | 
| Howard Hinnant | 22ce0b4 | 2010-07-14 21:14:52 | [diff] [blame] | 5558 | match_results<const _CharT*, _Allocator>& __m, | 
| Howard Hinnant | 41fb6e1 | 2011-03-26 20:02:27 | [diff] [blame] | 5559 | regex_constants::match_flag_type __flags, bool __at_first) const | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 5560 | { | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 5561 | deque<__state> __states; | 
| Howard Hinnant | 22ce0b4 | 2010-07-14 21:14:52 | [diff] [blame] | 5562 | ptrdiff_t __highest_j = 0; | 
| Howard Hinnant | 9996844 | 2011-11-29 18:15:50 | [diff] [blame] | 5563 | ptrdiff_t _Np = _VSTD::distance(__first, __last); | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 5564 | __node* __st = __start_.get(); | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 5565 | if (__st) | 
|  | 5566 | { | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 5567 | __states.push_back(__state()); | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 5568 | __states.back().__do_ = 0; | 
|  | 5569 | __states.back().__first_ = __first; | 
|  | 5570 | __states.back().__current_ = __first; | 
|  | 5571 | __states.back().__last_ = __last; | 
|  | 5572 | __states.back().__loop_data_.resize(__loop_count()); | 
|  | 5573 | __states.back().__node_ = __st; | 
|  | 5574 | __states.back().__flags_ = __flags; | 
| Howard Hinnant | 41fb6e1 | 2011-03-26 20:02:27 | [diff] [blame] | 5575 | __states.back().__at_first_ = __at_first; | 
| Howard Hinnant | 68025ed | 2010-07-14 15:45:11 | [diff] [blame] | 5576 | bool __matched = false; | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 5577 | do | 
|  | 5578 | { | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 5579 | __state& __s = __states.back(); | 
|  | 5580 | if (__s.__node_) | 
|  | 5581 | __s.__node_->__exec(__s); | 
|  | 5582 | switch (__s.__do_) | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 5583 | { | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 5584 | case __state::__end_state: | 
| Howard Hinnant | ad2a7ab | 2010-07-27 17:24:17 | [diff] [blame] | 5585 | if (!__matched || __highest_j < __s.__current_ - __s.__first_) | 
| Howard Hinnant | 68025ed | 2010-07-14 15:45:11 | [diff] [blame] | 5586 | __highest_j = __s.__current_ - __s.__first_; | 
| Howard Hinnant | ad2a7ab | 2010-07-27 17:24:17 | [diff] [blame] | 5587 | __matched = true; | 
| Howard Hinnant | 9996844 | 2011-11-29 18:15:50 | [diff] [blame] | 5588 | if (__highest_j == _Np) | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 5589 | __states.clear(); | 
|  | 5590 | else | 
|  | 5591 | __states.pop_back(); | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 5592 | break; | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 5593 | case __state::__consume_input: | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 5594 | break; | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 5595 | case __state::__accept_and_consume: | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 5596 | __states.push_front(_VSTD::move(__s)); | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 5597 | __states.pop_back(); | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 5598 | break; | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 5599 | case __state::__repeat: | 
|  | 5600 | case __state::__accept_but_not_consume: | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 5601 | break; | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 5602 | case __state::__split: | 
|  | 5603 | { | 
|  | 5604 | __state __snext = __s; | 
|  | 5605 | __s.__node_->__exec_split(true, __s); | 
|  | 5606 | __snext.__node_->__exec_split(false, __snext); | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 5607 | __states.push_back(_VSTD::move(__snext)); | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 5608 | } | 
|  | 5609 | break; | 
|  | 5610 | case __state::__reject: | 
|  | 5611 | __states.pop_back(); | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 5612 | break; | 
|  | 5613 | default: | 
| Howard Hinnant | d444470 | 2010-08-11 17:04:31 | [diff] [blame] | 5614 | #ifndef _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | ad2a7ab | 2010-07-27 17:24:17 | [diff] [blame] | 5615 | throw regex_error(regex_constants::__re_err_unknown); | 
| Howard Hinnant | d444470 | 2010-08-11 17:04:31 | [diff] [blame] | 5616 | #endif | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 5617 | break; | 
|  | 5618 | } | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 5619 | } while (!__states.empty()); | 
| Howard Hinnant | 68025ed | 2010-07-14 15:45:11 | [diff] [blame] | 5620 | if (__matched) | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 5621 | { | 
|  | 5622 | __m.__matches_[0].first = __first; | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 5623 | __m.__matches_[0].second = _VSTD::next(__first, __highest_j); | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 5624 | __m.__matches_[0].matched = true; | 
|  | 5625 | return true; | 
|  | 5626 | } | 
|  | 5627 | } | 
|  | 5628 | return false; | 
|  | 5629 | } | 
|  | 5630 |  | 
|  | 5631 | template <class _CharT, class _Traits> | 
| Howard Hinnant | 22ce0b4 | 2010-07-14 21:14:52 | [diff] [blame] | 5632 | template <class _Allocator> | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 5633 | bool | 
|  | 5634 | basic_regex<_CharT, _Traits>::__match_at_start_posix_subs( | 
| Howard Hinnant | 22ce0b4 | 2010-07-14 21:14:52 | [diff] [blame] | 5635 | const _CharT* __first, const _CharT* __last, | 
|  | 5636 | match_results<const _CharT*, _Allocator>& __m, | 
| Howard Hinnant | 41fb6e1 | 2011-03-26 20:02:27 | [diff] [blame] | 5637 | regex_constants::match_flag_type __flags, bool __at_first) const | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 5638 | { | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 5639 | vector<__state> __states; | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 5640 | __state __best_state; | 
| Howard Hinnant | 22ce0b4 | 2010-07-14 21:14:52 | [diff] [blame] | 5641 | ptrdiff_t __j = 0; | 
|  | 5642 | ptrdiff_t __highest_j = 0; | 
| Howard Hinnant | 9996844 | 2011-11-29 18:15:50 | [diff] [blame] | 5643 | ptrdiff_t _Np = _VSTD::distance(__first, __last); | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 5644 | __node* __st = __start_.get(); | 
| Howard Hinnant | e77aa5e | 2010-07-08 17:43:58 | [diff] [blame] | 5645 | if (__st) | 
|  | 5646 | { | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 5647 | __states.push_back(__state()); | 
|  | 5648 | __states.back().__do_ = 0; | 
|  | 5649 | __states.back().__first_ = __first; | 
|  | 5650 | __states.back().__current_ = __first; | 
|  | 5651 | __states.back().__last_ = __last; | 
|  | 5652 | __states.back().__sub_matches_.resize(mark_count()); | 
|  | 5653 | __states.back().__loop_data_.resize(__loop_count()); | 
|  | 5654 | __states.back().__node_ = __st; | 
|  | 5655 | __states.back().__flags_ = __flags; | 
| Howard Hinnant | 41fb6e1 | 2011-03-26 20:02:27 | [diff] [blame] | 5656 | __states.back().__at_first_ = __at_first; | 
| Howard Hinnant | 22ce0b4 | 2010-07-14 21:14:52 | [diff] [blame] | 5657 | const _CharT* __current = __first; | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 5658 | bool __matched = false; | 
| Howard Hinnant | e77aa5e | 2010-07-08 17:43:58 | [diff] [blame] | 5659 | do | 
|  | 5660 | { | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 5661 | __state& __s = __states.back(); | 
|  | 5662 | if (__s.__node_) | 
|  | 5663 | __s.__node_->__exec(__s); | 
|  | 5664 | switch (__s.__do_) | 
| Howard Hinnant | e77aa5e | 2010-07-08 17:43:58 | [diff] [blame] | 5665 | { | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 5666 | case __state::__end_state: | 
| Howard Hinnant | ad2a7ab | 2010-07-27 17:24:17 | [diff] [blame] | 5667 | if (!__matched || __highest_j < __s.__current_ - __s.__first_) | 
| Howard Hinnant | e77aa5e | 2010-07-08 17:43:58 | [diff] [blame] | 5668 | { | 
| Howard Hinnant | ad2a7ab | 2010-07-27 17:24:17 | [diff] [blame] | 5669 | __highest_j = __s.__current_ - __s.__first_; | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 5670 | __best_state = __s; | 
| Howard Hinnant | e77aa5e | 2010-07-08 17:43:58 | [diff] [blame] | 5671 | } | 
| Howard Hinnant | ad2a7ab | 2010-07-27 17:24:17 | [diff] [blame] | 5672 | __matched = true; | 
| Howard Hinnant | 9996844 | 2011-11-29 18:15:50 | [diff] [blame] | 5673 | if (__highest_j == _Np) | 
| Howard Hinnant | ad2a7ab | 2010-07-27 17:24:17 | [diff] [blame] | 5674 | __states.clear(); | 
|  | 5675 | else | 
|  | 5676 | __states.pop_back(); | 
| Howard Hinnant | e77aa5e | 2010-07-08 17:43:58 | [diff] [blame] | 5677 | break; | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 5678 | case __state::__accept_and_consume: | 
| Howard Hinnant | cba352d | 2010-07-12 18:16:05 | [diff] [blame] | 5679 | __j += __s.__current_ - __current; | 
|  | 5680 | __current = __s.__current_; | 
| Howard Hinnant | e77aa5e | 2010-07-08 17:43:58 | [diff] [blame] | 5681 | break; | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 5682 | case __state::__repeat: | 
|  | 5683 | case __state::__accept_but_not_consume: | 
| Howard Hinnant | e77aa5e | 2010-07-08 17:43:58 | [diff] [blame] | 5684 | break; | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 5685 | case __state::__split: | 
|  | 5686 | { | 
|  | 5687 | __state __snext = __s; | 
|  | 5688 | __s.__node_->__exec_split(true, __s); | 
|  | 5689 | __snext.__node_->__exec_split(false, __snext); | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 5690 | __states.push_back(_VSTD::move(__snext)); | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 5691 | } | 
|  | 5692 | break; | 
|  | 5693 | case __state::__reject: | 
|  | 5694 | __states.pop_back(); | 
| Howard Hinnant | e77aa5e | 2010-07-08 17:43:58 | [diff] [blame] | 5695 | break; | 
|  | 5696 | default: | 
| Howard Hinnant | d444470 | 2010-08-11 17:04:31 | [diff] [blame] | 5697 | #ifndef _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | ad2a7ab | 2010-07-27 17:24:17 | [diff] [blame] | 5698 | throw regex_error(regex_constants::__re_err_unknown); | 
| Howard Hinnant | d444470 | 2010-08-11 17:04:31 | [diff] [blame] | 5699 | #endif | 
| Howard Hinnant | e77aa5e | 2010-07-08 17:43:58 | [diff] [blame] | 5700 | break; | 
|  | 5701 | } | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 5702 | } while (!__states.empty()); | 
|  | 5703 | if (__matched) | 
| Howard Hinnant | e77aa5e | 2010-07-08 17:43:58 | [diff] [blame] | 5704 | { | 
|  | 5705 | __m.__matches_[0].first = __first; | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 5706 | __m.__matches_[0].second = _VSTD::next(__first, __highest_j); | 
| Howard Hinnant | e77aa5e | 2010-07-08 17:43:58 | [diff] [blame] | 5707 | __m.__matches_[0].matched = true; | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 5708 | for (unsigned __i = 0; __i < __best_state.__sub_matches_.size(); ++__i) | 
|  | 5709 | __m.__matches_[__i+1] = __best_state.__sub_matches_[__i]; | 
| Howard Hinnant | e77aa5e | 2010-07-08 17:43:58 | [diff] [blame] | 5710 | return true; | 
|  | 5711 | } | 
|  | 5712 | } | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 5713 | return false; | 
|  | 5714 | } | 
|  | 5715 |  | 
|  | 5716 | template <class _CharT, class _Traits> | 
| Howard Hinnant | 22ce0b4 | 2010-07-14 21:14:52 | [diff] [blame] | 5717 | template <class _Allocator> | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 5718 | bool | 
|  | 5719 | basic_regex<_CharT, _Traits>::__match_at_start( | 
| Howard Hinnant | 22ce0b4 | 2010-07-14 21:14:52 | [diff] [blame] | 5720 | const _CharT* __first, const _CharT* __last, | 
|  | 5721 | match_results<const _CharT*, _Allocator>& __m, | 
| Howard Hinnant | 41fb6e1 | 2011-03-26 20:02:27 | [diff] [blame] | 5722 | regex_constants::match_flag_type __flags, bool __at_first) const | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 5723 | { | 
| Howard Hinnant | ad2a7ab | 2010-07-27 17:24:17 | [diff] [blame] | 5724 | if ((__flags_ & 0x1F0) == ECMAScript) | 
| Howard Hinnant | 41fb6e1 | 2011-03-26 20:02:27 | [diff] [blame] | 5725 | return __match_at_start_ecma(__first, __last, __m, __flags, __at_first); | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 5726 | if (mark_count() == 0) | 
| Howard Hinnant | 41fb6e1 | 2011-03-26 20:02:27 | [diff] [blame] | 5727 | return __match_at_start_posix_nosubs(__first, __last, __m, __flags, __at_first); | 
|  | 5728 | return __match_at_start_posix_subs(__first, __last, __m, __flags, __at_first); | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 5729 | } | 
|  | 5730 |  | 
|  | 5731 | template <class _CharT, class _Traits> | 
| Howard Hinnant | 22ce0b4 | 2010-07-14 21:14:52 | [diff] [blame] | 5732 | template <class _Allocator> | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 5733 | bool | 
| Howard Hinnant | 9b80f2b | 2010-06-30 17:22:19 | [diff] [blame] | 5734 | basic_regex<_CharT, _Traits>::__search( | 
| Howard Hinnant | 22ce0b4 | 2010-07-14 21:14:52 | [diff] [blame] | 5735 | const _CharT* __first, const _CharT* __last, | 
|  | 5736 | match_results<const _CharT*, _Allocator>& __m, | 
| Howard Hinnant | 9b80f2b | 2010-06-30 17:22:19 | [diff] [blame] | 5737 | regex_constants::match_flag_type __flags) const | 
|  | 5738 | { | 
| Howard Hinnant | a712c72 | 2010-08-16 20:21:16 | [diff] [blame] | 5739 | __m.__init(1 + mark_count(), __first, __last, | 
|  | 5740 | __flags & regex_constants::__no_update_pos); | 
| Howard Hinnant | 41fb6e1 | 2011-03-26 20:02:27 | [diff] [blame] | 5741 | if (__match_at_start(__first, __last, __m, __flags, true)) | 
| Howard Hinnant | 9b80f2b | 2010-06-30 17:22:19 | [diff] [blame] | 5742 | { | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 5743 | __m.__prefix_.second = __m[0].first; | 
|  | 5744 | __m.__prefix_.matched = __m.__prefix_.first != __m.__prefix_.second; | 
|  | 5745 | __m.__suffix_.first = __m[0].second; | 
|  | 5746 | __m.__suffix_.matched = __m.__suffix_.first != __m.__suffix_.second; | 
|  | 5747 | return true; | 
|  | 5748 | } | 
| Howard Hinnant | 8daa733 | 2010-07-29 01:15:27 | [diff] [blame] | 5749 | if (__first != __last && !(__flags & regex_constants::match_continuous)) | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 5750 | { | 
| Howard Hinnant | f3dcca0 | 2010-07-29 15:17:28 | [diff] [blame] | 5751 | __flags |= regex_constants::match_prev_avail; | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 5752 | for (++__first; __first != __last; ++__first) | 
| Howard Hinnant | 9b80f2b | 2010-06-30 17:22:19 | [diff] [blame] | 5753 | { | 
| Howard Hinnant | f3dcca0 | 2010-07-29 15:17:28 | [diff] [blame] | 5754 | __m.__matches_.assign(__m.size(), __m.__unmatched_); | 
| Howard Hinnant | 41fb6e1 | 2011-03-26 20:02:27 | [diff] [blame] | 5755 | if (__match_at_start(__first, __last, __m, __flags, false)) | 
| Howard Hinnant | 9b80f2b | 2010-06-30 17:22:19 | [diff] [blame] | 5756 | { | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 5757 | __m.__prefix_.second = __m[0].first; | 
|  | 5758 | __m.__prefix_.matched = __m.__prefix_.first != __m.__prefix_.second; | 
|  | 5759 | __m.__suffix_.first = __m[0].second; | 
|  | 5760 | __m.__suffix_.matched = __m.__suffix_.first != __m.__suffix_.second; | 
|  | 5761 | return true; | 
| Howard Hinnant | 9b80f2b | 2010-06-30 17:22:19 | [diff] [blame] | 5762 | } | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 5763 | __m.__matches_.assign(__m.size(), __m.__unmatched_); | 
| Howard Hinnant | 9b80f2b | 2010-06-30 17:22:19 | [diff] [blame] | 5764 | } | 
|  | 5765 | } | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 5766 | __m.__matches_.clear(); | 
|  | 5767 | return false; | 
| Howard Hinnant | 9b80f2b | 2010-06-30 17:22:19 | [diff] [blame] | 5768 | } | 
|  | 5769 |  | 
| Howard Hinnant | 7e9d84b | 2010-06-30 00:21:42 | [diff] [blame] | 5770 | template <class _BidirectionalIterator, class _Allocator, class _CharT, class _Traits> | 
| Howard Hinnant | 9b80f2b | 2010-06-30 17:22:19 | [diff] [blame] | 5771 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 7e9d84b | 2010-06-30 00:21:42 | [diff] [blame] | 5772 | bool | 
|  | 5773 | regex_search(_BidirectionalIterator __first, _BidirectionalIterator __last, | 
|  | 5774 | match_results<_BidirectionalIterator, _Allocator>& __m, | 
|  | 5775 | const basic_regex<_CharT, _Traits>& __e, | 
| Howard Hinnant | 9b80f2b | 2010-06-30 17:22:19 | [diff] [blame] | 5776 | regex_constants::match_flag_type __flags = regex_constants::match_default) | 
|  | 5777 | { | 
| Howard Hinnant | 22ce0b4 | 2010-07-14 21:14:52 | [diff] [blame] | 5778 | basic_string<_CharT> __s(__first, __last); | 
|  | 5779 | match_results<const _CharT*> __mc; | 
|  | 5780 | bool __r = __e.__search(__s.data(), __s.data() + __s.size(), __mc, __flags); | 
| Howard Hinnant | a712c72 | 2010-08-16 20:21:16 | [diff] [blame] | 5781 | __m.__assign(__first, __last, __mc, __flags & regex_constants::__no_update_pos); | 
| Howard Hinnant | 22ce0b4 | 2010-07-14 21:14:52 | [diff] [blame] | 5782 | return __r; | 
|  | 5783 | } | 
|  | 5784 |  | 
|  | 5785 | template <class _Allocator, class _CharT, class _Traits> | 
|  | 5786 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 5787 | bool | 
|  | 5788 | regex_search(const _CharT* __first, const _CharT* __last, | 
|  | 5789 | match_results<const _CharT*, _Allocator>& __m, | 
|  | 5790 | const basic_regex<_CharT, _Traits>& __e, | 
|  | 5791 | regex_constants::match_flag_type __flags = regex_constants::match_default) | 
|  | 5792 | { | 
| Howard Hinnant | 9b80f2b | 2010-06-30 17:22:19 | [diff] [blame] | 5793 | return __e.__search(__first, __last, __m, __flags); | 
|  | 5794 | } | 
| Howard Hinnant | 7e9d84b | 2010-06-30 00:21:42 | [diff] [blame] | 5795 |  | 
|  | 5796 | template <class _BidirectionalIterator, class _CharT, class _Traits> | 
|  | 5797 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 5798 | bool | 
|  | 5799 | regex_search(_BidirectionalIterator __first, _BidirectionalIterator __last, | 
|  | 5800 | const basic_regex<_CharT, _Traits>& __e, | 
|  | 5801 | regex_constants::match_flag_type __flags = regex_constants::match_default) | 
|  | 5802 | { | 
| Howard Hinnant | 22ce0b4 | 2010-07-14 21:14:52 | [diff] [blame] | 5803 | basic_string<_CharT> __s(__first, __last); | 
|  | 5804 | match_results<const _CharT*> __mc; | 
|  | 5805 | return __e.__search(__s.data(), __s.data() + __s.size(), __mc, __flags); | 
|  | 5806 | } | 
|  | 5807 |  | 
|  | 5808 | template <class _CharT, class _Traits> | 
|  | 5809 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 5810 | bool | 
|  | 5811 | regex_search(const _CharT* __first, const _CharT* __last, | 
|  | 5812 | const basic_regex<_CharT, _Traits>& __e, | 
|  | 5813 | regex_constants::match_flag_type __flags = regex_constants::match_default) | 
|  | 5814 | { | 
|  | 5815 | match_results<const _CharT*> __mc; | 
|  | 5816 | return __e.__search(__first, __last, __mc, __flags); | 
| Howard Hinnant | 7e9d84b | 2010-06-30 00:21:42 | [diff] [blame] | 5817 | } | 
|  | 5818 |  | 
|  | 5819 | template <class _CharT, class _Allocator, class _Traits> | 
|  | 5820 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 5821 | bool | 
|  | 5822 | regex_search(const _CharT* __str, match_results<const _CharT*, _Allocator>& __m, | 
|  | 5823 | const basic_regex<_CharT, _Traits>& __e, | 
|  | 5824 | regex_constants::match_flag_type __flags = regex_constants::match_default) | 
|  | 5825 | { | 
| Howard Hinnant | 22ce0b4 | 2010-07-14 21:14:52 | [diff] [blame] | 5826 | return __e.__search(__str, __str + _Traits::length(__str), __m, __flags); | 
| Howard Hinnant | 7e9d84b | 2010-06-30 00:21:42 | [diff] [blame] | 5827 | } | 
|  | 5828 |  | 
|  | 5829 | template <class _CharT, class _Traits> | 
|  | 5830 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 5831 | bool | 
|  | 5832 | regex_search(const _CharT* __str, const basic_regex<_CharT, _Traits>& __e, | 
|  | 5833 | regex_constants::match_flag_type __flags = regex_constants::match_default) | 
|  | 5834 | { | 
| Howard Hinnant | 22ce0b4 | 2010-07-14 21:14:52 | [diff] [blame] | 5835 | match_results<const _CharT*> __m; | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 5836 | return _VSTD::regex_search(__str, __m, __e, __flags); | 
| Howard Hinnant | 7e9d84b | 2010-06-30 00:21:42 | [diff] [blame] | 5837 | } | 
|  | 5838 |  | 
|  | 5839 | template <class _ST, class _SA, class _CharT, class _Traits> | 
|  | 5840 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 5841 | bool | 
|  | 5842 | regex_search(const basic_string<_CharT, _ST, _SA>& __s, | 
|  | 5843 | const basic_regex<_CharT, _Traits>& __e, | 
|  | 5844 | regex_constants::match_flag_type __flags = regex_constants::match_default) | 
|  | 5845 | { | 
| Howard Hinnant | 22ce0b4 | 2010-07-14 21:14:52 | [diff] [blame] | 5846 | match_results<const _CharT*> __mc; | 
|  | 5847 | return __e.__search(__s.data(), __s.data() + __s.size(), __mc, __flags); | 
| Howard Hinnant | 7e9d84b | 2010-06-30 00:21:42 | [diff] [blame] | 5848 | } | 
|  | 5849 |  | 
|  | 5850 | template <class _ST, class _SA, class _Allocator, class _CharT, class _Traits> | 
|  | 5851 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 5852 | bool | 
|  | 5853 | regex_search(const basic_string<_CharT, _ST, _SA>& __s, | 
|  | 5854 | match_results<typename basic_string<_CharT, _ST, _SA>::const_iterator, _Allocator>& __m, | 
|  | 5855 | const basic_regex<_CharT, _Traits>& __e, | 
|  | 5856 | regex_constants::match_flag_type __flags = regex_constants::match_default) | 
|  | 5857 | { | 
| Howard Hinnant | 22ce0b4 | 2010-07-14 21:14:52 | [diff] [blame] | 5858 | match_results<const _CharT*> __mc; | 
|  | 5859 | bool __r = __e.__search(__s.data(), __s.data() + __s.size(), __mc, __flags); | 
| Howard Hinnant | a712c72 | 2010-08-16 20:21:16 | [diff] [blame] | 5860 | __m.__assign(__s.begin(), __s.end(), __mc, __flags & regex_constants::__no_update_pos); | 
| Howard Hinnant | 22ce0b4 | 2010-07-14 21:14:52 | [diff] [blame] | 5861 | return __r; | 
| Howard Hinnant | 7e9d84b | 2010-06-30 00:21:42 | [diff] [blame] | 5862 | } | 
|  | 5863 |  | 
|  | 5864 | // regex_match | 
|  | 5865 |  | 
|  | 5866 | template <class _BidirectionalIterator, class _Allocator, class _CharT, class _Traits> | 
|  | 5867 | bool | 
|  | 5868 | regex_match(_BidirectionalIterator __first, _BidirectionalIterator __last, | 
|  | 5869 | match_results<_BidirectionalIterator, _Allocator>& __m, | 
|  | 5870 | const basic_regex<_CharT, _Traits>& __e, | 
|  | 5871 | regex_constants::match_flag_type __flags = regex_constants::match_default) | 
|  | 5872 | { | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 5873 | bool __r = _VSTD::regex_search(__first, __last, __m, __e, | 
| Howard Hinnant | 7e9d84b | 2010-06-30 00:21:42 | [diff] [blame] | 5874 | __flags | regex_constants::match_continuous); | 
|  | 5875 | if (__r) | 
|  | 5876 | { | 
|  | 5877 | __r = !__m.suffix().matched; | 
|  | 5878 | if (!__r) | 
|  | 5879 | __m.__matches_.clear(); | 
|  | 5880 | } | 
|  | 5881 | return __r; | 
|  | 5882 | } | 
|  | 5883 |  | 
|  | 5884 | template <class _BidirectionalIterator, class _CharT, class _Traits> | 
|  | 5885 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 5886 | bool | 
|  | 5887 | regex_match(_BidirectionalIterator __first, _BidirectionalIterator __last, | 
|  | 5888 | const basic_regex<_CharT, _Traits>& __e, | 
|  | 5889 | regex_constants::match_flag_type __flags = regex_constants::match_default) | 
|  | 5890 | { | 
|  | 5891 | match_results<_BidirectionalIterator> __m; | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 5892 | return _VSTD::regex_match(__first, __last, __m, __e, __flags); | 
| Howard Hinnant | 7e9d84b | 2010-06-30 00:21:42 | [diff] [blame] | 5893 | } | 
|  | 5894 |  | 
|  | 5895 | template <class _CharT, class _Allocator, class _Traits> | 
|  | 5896 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 5897 | bool | 
|  | 5898 | regex_match(const _CharT* __str, match_results<const _CharT*, _Allocator>& __m, | 
|  | 5899 | const basic_regex<_CharT, _Traits>& __e, | 
|  | 5900 | regex_constants::match_flag_type __flags = regex_constants::match_default) | 
|  | 5901 | { | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 5902 | return _VSTD::regex_match(__str, __str + _Traits::length(__str), __m, __e, __flags); | 
| Howard Hinnant | 7e9d84b | 2010-06-30 00:21:42 | [diff] [blame] | 5903 | } | 
|  | 5904 |  | 
|  | 5905 | template <class _ST, class _SA, class _Allocator, class _CharT, class _Traits> | 
|  | 5906 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 5907 | bool | 
|  | 5908 | regex_match(const basic_string<_CharT, _ST, _SA>& __s, | 
|  | 5909 | match_results<typename basic_string<_CharT, _ST, _SA>::const_iterator, _Allocator>& __m, | 
|  | 5910 | const basic_regex<_CharT, _Traits>& __e, | 
|  | 5911 | regex_constants::match_flag_type __flags = regex_constants::match_default) | 
|  | 5912 | { | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 5913 | return _VSTD::regex_match(__s.begin(), __s.end(), __m, __e, __flags); | 
| Howard Hinnant | 7e9d84b | 2010-06-30 00:21:42 | [diff] [blame] | 5914 | } | 
|  | 5915 |  | 
|  | 5916 | template <class _CharT, class _Traits> | 
|  | 5917 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 5918 | bool | 
|  | 5919 | regex_match(const _CharT* __str, const basic_regex<_CharT, _Traits>& __e, | 
|  | 5920 | regex_constants::match_flag_type __flags = regex_constants::match_default) | 
|  | 5921 | { | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 5922 | return _VSTD::regex_match(__str, __str + _Traits::length(__str), __e, __flags); | 
| Howard Hinnant | 7e9d84b | 2010-06-30 00:21:42 | [diff] [blame] | 5923 | } | 
|  | 5924 |  | 
|  | 5925 | template <class _ST, class _SA, class _CharT, class _Traits> | 
|  | 5926 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 5927 | bool | 
|  | 5928 | regex_match(const basic_string<_CharT, _ST, _SA>& __s, | 
|  | 5929 | const basic_regex<_CharT, _Traits>& __e, | 
|  | 5930 | regex_constants::match_flag_type __flags = regex_constants::match_default) | 
|  | 5931 | { | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 5932 | return _VSTD::regex_match(__s.begin(), __s.end(), __e, __flags); | 
| Howard Hinnant | 7e9d84b | 2010-06-30 00:21:42 | [diff] [blame] | 5933 | } | 
|  | 5934 |  | 
| Howard Hinnant | a712c72 | 2010-08-16 20:21:16 | [diff] [blame] | 5935 | // regex_iterator | 
|  | 5936 |  | 
|  | 5937 | template <class _BidirectionalIterator, | 
|  | 5938 | class _CharT = typename iterator_traits<_BidirectionalIterator>::value_type, | 
|  | 5939 | class _Traits = regex_traits<_CharT> > | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 5940 | class _LIBCPP_VISIBLE regex_iterator | 
| Howard Hinnant | a712c72 | 2010-08-16 20:21:16 | [diff] [blame] | 5941 | { | 
|  | 5942 | public: | 
|  | 5943 | typedef basic_regex<_CharT, _Traits> regex_type; | 
|  | 5944 | typedef match_results<_BidirectionalIterator> value_type; | 
|  | 5945 | typedef ptrdiff_t difference_type; | 
|  | 5946 | typedef const value_type* pointer; | 
|  | 5947 | typedef const value_type& reference; | 
|  | 5948 | typedef forward_iterator_tag iterator_category; | 
|  | 5949 |  | 
|  | 5950 | private: | 
|  | 5951 | _BidirectionalIterator __begin_; | 
|  | 5952 | _BidirectionalIterator __end_; | 
|  | 5953 | const regex_type* __pregex_; | 
|  | 5954 | regex_constants::match_flag_type __flags_; | 
|  | 5955 | value_type __match_; | 
|  | 5956 |  | 
|  | 5957 | public: | 
|  | 5958 | regex_iterator(); | 
|  | 5959 | regex_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b, | 
|  | 5960 | const regex_type& __re, | 
|  | 5961 | regex_constants::match_flag_type __m = regex_constants::match_default); | 
|  | 5962 |  | 
|  | 5963 | bool operator==(const regex_iterator& __x) const; | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 5964 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | a712c72 | 2010-08-16 20:21:16 | [diff] [blame] | 5965 | bool operator!=(const regex_iterator& __x) const {return !(*this == __x);} | 
|  | 5966 |  | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 5967 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | a712c72 | 2010-08-16 20:21:16 | [diff] [blame] | 5968 | reference operator*() const {return __match_;} | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 5969 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | a712c72 | 2010-08-16 20:21:16 | [diff] [blame] | 5970 | pointer operator->() const {return &__match_;} | 
|  | 5971 |  | 
|  | 5972 | regex_iterator& operator++(); | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 5973 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | a712c72 | 2010-08-16 20:21:16 | [diff] [blame] | 5974 | regex_iterator operator++(int) | 
|  | 5975 | { | 
|  | 5976 | regex_iterator __t(*this); | 
|  | 5977 | ++(*this); | 
|  | 5978 | return __t; | 
|  | 5979 | } | 
|  | 5980 | }; | 
|  | 5981 |  | 
|  | 5982 | template <class _BidirectionalIterator, class _CharT, class _Traits> | 
|  | 5983 | regex_iterator<_BidirectionalIterator, _CharT, _Traits>::regex_iterator() | 
|  | 5984 | : __begin_(), __end_(), __pregex_(nullptr), __flags_(), __match_() | 
|  | 5985 | { | 
|  | 5986 | } | 
|  | 5987 |  | 
|  | 5988 | template <class _BidirectionalIterator, class _CharT, class _Traits> | 
|  | 5989 | regex_iterator<_BidirectionalIterator, _CharT, _Traits>:: | 
|  | 5990 | regex_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b, | 
|  | 5991 | const regex_type& __re, regex_constants::match_flag_type __m) | 
|  | 5992 | : __begin_(__a), | 
|  | 5993 | __end_(__b), | 
|  | 5994 | __pregex_(&__re), | 
|  | 5995 | __flags_(__m) | 
|  | 5996 | { | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 5997 | _VSTD::regex_search(__begin_, __end_, __match_, *__pregex_, __flags_); | 
| Howard Hinnant | a712c72 | 2010-08-16 20:21:16 | [diff] [blame] | 5998 | } | 
|  | 5999 |  | 
|  | 6000 | template <class _BidirectionalIterator, class _CharT, class _Traits> | 
|  | 6001 | bool | 
|  | 6002 | regex_iterator<_BidirectionalIterator, _CharT, _Traits>:: | 
|  | 6003 | operator==(const regex_iterator& __x) const | 
|  | 6004 | { | 
|  | 6005 | if (__match_.empty() && __x.__match_.empty()) | 
|  | 6006 | return true; | 
|  | 6007 | if (__match_.empty() || __x.__match_.empty()) | 
|  | 6008 | return false; | 
|  | 6009 | return __begin_ == __x.__begin_ && | 
|  | 6010 | __end_ == __x.__end_ && | 
|  | 6011 | __pregex_ == __x.__pregex_ && | 
|  | 6012 | __flags_ == __x.__flags_ && | 
|  | 6013 | __match_[0] == __x.__match_[0]; | 
|  | 6014 | } | 
|  | 6015 |  | 
|  | 6016 | template <class _BidirectionalIterator, class _CharT, class _Traits> | 
|  | 6017 | regex_iterator<_BidirectionalIterator, _CharT, _Traits>& | 
|  | 6018 | regex_iterator<_BidirectionalIterator, _CharT, _Traits>::operator++() | 
|  | 6019 | { | 
|  | 6020 | __flags_ |= regex_constants::__no_update_pos; | 
|  | 6021 | _BidirectionalIterator __start = __match_[0].second; | 
|  | 6022 | if (__match_.length() == 0) | 
|  | 6023 | { | 
|  | 6024 | if (__start == __end_) | 
|  | 6025 | { | 
|  | 6026 | __match_ = value_type(); | 
|  | 6027 | return *this; | 
|  | 6028 | } | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 6029 | else if (_VSTD::regex_search(__start, __end_, __match_, *__pregex_, | 
| Howard Hinnant | a712c72 | 2010-08-16 20:21:16 | [diff] [blame] | 6030 | __flags_ | regex_constants::match_not_null | | 
|  | 6031 | regex_constants::match_continuous)) | 
|  | 6032 | return *this; | 
|  | 6033 | else | 
|  | 6034 | ++__start; | 
|  | 6035 | } | 
|  | 6036 | __flags_ |= regex_constants::match_prev_avail; | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 6037 | if (!_VSTD::regex_search(__start, __end_, __match_, *__pregex_, __flags_)) | 
| Howard Hinnant | a712c72 | 2010-08-16 20:21:16 | [diff] [blame] | 6038 | __match_ = value_type(); | 
|  | 6039 | return *this; | 
|  | 6040 | } | 
|  | 6041 |  | 
|  | 6042 | typedef regex_iterator<const char*> cregex_iterator; | 
|  | 6043 | typedef regex_iterator<const wchar_t*> wcregex_iterator; | 
|  | 6044 | typedef regex_iterator<string::const_iterator> sregex_iterator; | 
|  | 6045 | typedef regex_iterator<wstring::const_iterator> wsregex_iterator; | 
|  | 6046 |  | 
|  | 6047 | // regex_token_iterator | 
|  | 6048 |  | 
|  | 6049 | template <class _BidirectionalIterator, | 
|  | 6050 | class _CharT = typename iterator_traits<_BidirectionalIterator>::value_type, | 
|  | 6051 | class _Traits = regex_traits<_CharT> > | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 6052 | class _LIBCPP_VISIBLE regex_token_iterator | 
| Howard Hinnant | a712c72 | 2010-08-16 20:21:16 | [diff] [blame] | 6053 | { | 
|  | 6054 | public: | 
|  | 6055 | typedef basic_regex<_CharT, _Traits> regex_type; | 
|  | 6056 | typedef sub_match<_BidirectionalIterator> value_type; | 
|  | 6057 | typedef ptrdiff_t difference_type; | 
|  | 6058 | typedef const value_type* pointer; | 
|  | 6059 | typedef const value_type& reference; | 
|  | 6060 | typedef forward_iterator_tag iterator_category; | 
|  | 6061 |  | 
| Howard Hinnant | 262b779 | 2010-08-17 20:42:03 | [diff] [blame] | 6062 | private: | 
|  | 6063 | typedef regex_iterator<_BidirectionalIterator, _CharT, _Traits> _Position; | 
|  | 6064 |  | 
|  | 6065 | _Position __position_; | 
|  | 6066 | const value_type* __result_; | 
|  | 6067 | value_type __suffix_; | 
|  | 6068 | ptrdiff_t _N_; | 
|  | 6069 | vector<int> __subs_; | 
|  | 6070 |  | 
|  | 6071 | public: | 
| Howard Hinnant | a712c72 | 2010-08-16 20:21:16 | [diff] [blame] | 6072 | regex_token_iterator(); | 
|  | 6073 | regex_token_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b, | 
|  | 6074 | const regex_type& __re, int __submatch = 0, | 
| Howard Hinnant | 262b779 | 2010-08-17 20:42:03 | [diff] [blame] | 6075 | regex_constants::match_flag_type __m = | 
|  | 6076 | regex_constants::match_default); | 
| Howard Hinnant | a712c72 | 2010-08-16 20:21:16 | [diff] [blame] | 6077 | regex_token_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b, | 
|  | 6078 | const regex_type& __re, const vector<int>& __submatches, | 
| Howard Hinnant | 262b779 | 2010-08-17 20:42:03 | [diff] [blame] | 6079 | regex_constants::match_flag_type __m = | 
|  | 6080 | regex_constants::match_default); | 
| Howard Hinnant | e3e3291 | 2011-08-12 21:56:02 | [diff] [blame] | 6081 | #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS | 
| Howard Hinnant | a712c72 | 2010-08-16 20:21:16 | [diff] [blame] | 6082 | regex_token_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b, | 
| Howard Hinnant | 262b779 | 2010-08-17 20:42:03 | [diff] [blame] | 6083 | const regex_type& __re, | 
|  | 6084 | initializer_list<int> __submatches, | 
|  | 6085 | regex_constants::match_flag_type __m = | 
|  | 6086 | regex_constants::match_default); | 
| Howard Hinnant | e3e3291 | 2011-08-12 21:56:02 | [diff] [blame] | 6087 | #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS | 
| Howard Hinnant | 9996844 | 2011-11-29 18:15:50 | [diff] [blame] | 6088 | template <size_t _Np> | 
| Howard Hinnant | 262b779 | 2010-08-17 20:42:03 | [diff] [blame] | 6089 | regex_token_iterator(_BidirectionalIterator __a, | 
|  | 6090 | _BidirectionalIterator __b, | 
|  | 6091 | const regex_type& __re, | 
| Howard Hinnant | 9996844 | 2011-11-29 18:15:50 | [diff] [blame] | 6092 | const int (&__submatches)[_Np], | 
| Howard Hinnant | 262b779 | 2010-08-17 20:42:03 | [diff] [blame] | 6093 | regex_constants::match_flag_type __m = | 
|  | 6094 | regex_constants::match_default); | 
| Howard Hinnant | a712c72 | 2010-08-16 20:21:16 | [diff] [blame] | 6095 | regex_token_iterator(const regex_token_iterator&); | 
|  | 6096 | regex_token_iterator& operator=(const regex_token_iterator&); | 
|  | 6097 |  | 
| Howard Hinnant | 262b779 | 2010-08-17 20:42:03 | [diff] [blame] | 6098 | bool operator==(const regex_token_iterator& __x) const; | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 6099 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 262b779 | 2010-08-17 20:42:03 | [diff] [blame] | 6100 | bool operator!=(const regex_token_iterator& __x) const {return !(*this == __x);} | 
| Howard Hinnant | a712c72 | 2010-08-16 20:21:16 | [diff] [blame] | 6101 |  | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 6102 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 262b779 | 2010-08-17 20:42:03 | [diff] [blame] | 6103 | const value_type& operator*() const {return *__result_;} | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 6104 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 262b779 | 2010-08-17 20:42:03 | [diff] [blame] | 6105 | const value_type* operator->() const {return __result_;} | 
| Howard Hinnant | a712c72 | 2010-08-16 20:21:16 | [diff] [blame] | 6106 |  | 
|  | 6107 | regex_token_iterator& operator++(); | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 6108 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 262b779 | 2010-08-17 20:42:03 | [diff] [blame] | 6109 | regex_token_iterator operator++(int) | 
|  | 6110 | { | 
|  | 6111 | regex_token_iterator __t(*this); | 
|  | 6112 | ++(*this); | 
|  | 6113 | return __t; | 
|  | 6114 | } | 
|  | 6115 |  | 
|  | 6116 | private: | 
|  | 6117 | void __init(_BidirectionalIterator __a, _BidirectionalIterator __b); | 
| Howard Hinnant | a712c72 | 2010-08-16 20:21:16 | [diff] [blame] | 6118 | }; | 
|  | 6119 |  | 
| Howard Hinnant | 262b779 | 2010-08-17 20:42:03 | [diff] [blame] | 6120 | template <class _BidirectionalIterator, class _CharT, class _Traits> | 
|  | 6121 | regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>:: | 
|  | 6122 | regex_token_iterator() | 
|  | 6123 | : __result_(nullptr), | 
|  | 6124 | __suffix_(), | 
|  | 6125 | _N_(0) | 
|  | 6126 | { | 
|  | 6127 | } | 
|  | 6128 |  | 
|  | 6129 | template <class _BidirectionalIterator, class _CharT, class _Traits> | 
|  | 6130 | void | 
|  | 6131 | regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>:: | 
|  | 6132 | __init(_BidirectionalIterator __a, _BidirectionalIterator __b) | 
|  | 6133 | { | 
|  | 6134 | if (__position_ != _Position()) | 
|  | 6135 | { | 
|  | 6136 | if (__subs_[_N_] == -1) | 
|  | 6137 | __result_ = &__position_->prefix(); | 
|  | 6138 | else | 
|  | 6139 | __result_ = &(*__position_)[__subs_[_N_]]; | 
|  | 6140 | } | 
|  | 6141 | else if (__subs_[_N_] == -1) | 
|  | 6142 | { | 
|  | 6143 | __suffix_.matched = true; | 
|  | 6144 | __suffix_.first = __a; | 
|  | 6145 | __suffix_.second = __b; | 
|  | 6146 | __result_ = &__suffix_; | 
|  | 6147 | } | 
|  | 6148 | else | 
|  | 6149 | __result_ = nullptr; | 
|  | 6150 | } | 
|  | 6151 |  | 
|  | 6152 | template <class _BidirectionalIterator, class _CharT, class _Traits> | 
|  | 6153 | regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>:: | 
|  | 6154 | regex_token_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b, | 
|  | 6155 | const regex_type& __re, int __submatch, | 
|  | 6156 | regex_constants::match_flag_type __m) | 
|  | 6157 | : __position_(__a, __b, __re, __m), | 
|  | 6158 | _N_(0), | 
|  | 6159 | __subs_(1, __submatch) | 
|  | 6160 | { | 
|  | 6161 | __init(__a, __b); | 
|  | 6162 | } | 
|  | 6163 |  | 
|  | 6164 | template <class _BidirectionalIterator, class _CharT, class _Traits> | 
|  | 6165 | regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>:: | 
|  | 6166 | regex_token_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b, | 
|  | 6167 | const regex_type& __re, const vector<int>& __submatches, | 
|  | 6168 | regex_constants::match_flag_type __m) | 
|  | 6169 | : __position_(__a, __b, __re, __m), | 
|  | 6170 | _N_(0), | 
|  | 6171 | __subs_(__submatches) | 
|  | 6172 | { | 
|  | 6173 | __init(__a, __b); | 
|  | 6174 | } | 
|  | 6175 |  | 
| Howard Hinnant | e3e3291 | 2011-08-12 21:56:02 | [diff] [blame] | 6176 | #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS | 
|  | 6177 |  | 
| Howard Hinnant | 262b779 | 2010-08-17 20:42:03 | [diff] [blame] | 6178 | template <class _BidirectionalIterator, class _CharT, class _Traits> | 
|  | 6179 | regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>:: | 
|  | 6180 | regex_token_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b, | 
|  | 6181 | const regex_type& __re, | 
|  | 6182 | initializer_list<int> __submatches, | 
|  | 6183 | regex_constants::match_flag_type __m) | 
|  | 6184 | : __position_(__a, __b, __re, __m), | 
|  | 6185 | _N_(0), | 
|  | 6186 | __subs_(__submatches) | 
|  | 6187 | { | 
|  | 6188 | __init(__a, __b); | 
|  | 6189 | } | 
|  | 6190 |  | 
| Howard Hinnant | e3e3291 | 2011-08-12 21:56:02 | [diff] [blame] | 6191 | #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS | 
|  | 6192 |  | 
| Howard Hinnant | 262b779 | 2010-08-17 20:42:03 | [diff] [blame] | 6193 | template <class _BidirectionalIterator, class _CharT, class _Traits> | 
| Howard Hinnant | 9996844 | 2011-11-29 18:15:50 | [diff] [blame] | 6194 | template <size_t _Np> | 
| Howard Hinnant | 262b779 | 2010-08-17 20:42:03 | [diff] [blame] | 6195 | regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>:: | 
|  | 6196 | regex_token_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b, | 
|  | 6197 | const regex_type& __re, | 
| Howard Hinnant | 9996844 | 2011-11-29 18:15:50 | [diff] [blame] | 6198 | const int (&__submatches)[_Np], | 
| Howard Hinnant | 262b779 | 2010-08-17 20:42:03 | [diff] [blame] | 6199 | regex_constants::match_flag_type __m) | 
|  | 6200 | : __position_(__a, __b, __re, __m), | 
|  | 6201 | _N_(0), | 
| Howard Hinnant | 9996844 | 2011-11-29 18:15:50 | [diff] [blame] | 6202 | __subs_(__submatches, __submatches + _Np) | 
| Howard Hinnant | 262b779 | 2010-08-17 20:42:03 | [diff] [blame] | 6203 | { | 
|  | 6204 | __init(__a, __b); | 
|  | 6205 | } | 
|  | 6206 |  | 
|  | 6207 | template <class _BidirectionalIterator, class _CharT, class _Traits> | 
|  | 6208 | regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>:: | 
|  | 6209 | regex_token_iterator(const regex_token_iterator& __x) | 
|  | 6210 | : __position_(__x.__position_), | 
|  | 6211 | __result_(__x.__result_), | 
|  | 6212 | __suffix_(__x.__suffix_), | 
|  | 6213 | _N_(__x._N_), | 
|  | 6214 | __subs_(__x.__subs_) | 
|  | 6215 | { | 
|  | 6216 | if (__x.__result_ == &__x.__suffix_) | 
|  | 6217 | __result_ == &__suffix_; | 
|  | 6218 | } | 
|  | 6219 |  | 
|  | 6220 | template <class _BidirectionalIterator, class _CharT, class _Traits> | 
|  | 6221 | regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>& | 
|  | 6222 | regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>:: | 
|  | 6223 | operator=(const regex_token_iterator& __x) | 
|  | 6224 | { | 
|  | 6225 | if (this != &__x) | 
|  | 6226 | { | 
|  | 6227 | __position_ = __x.__position_; | 
|  | 6228 | if (__x.__result_ == &__x.__suffix_) | 
|  | 6229 | __result_ == &__suffix_; | 
|  | 6230 | else | 
|  | 6231 | __result_ = __x.__result_; | 
|  | 6232 | __suffix_ = __x.__suffix_; | 
|  | 6233 | _N_ = __x._N_; | 
|  | 6234 | __subs_ = __x.__subs_; | 
|  | 6235 | } | 
|  | 6236 | return *this; | 
|  | 6237 | } | 
|  | 6238 |  | 
|  | 6239 | template <class _BidirectionalIterator, class _CharT, class _Traits> | 
|  | 6240 | bool | 
|  | 6241 | regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>:: | 
|  | 6242 | operator==(const regex_token_iterator& __x) const | 
|  | 6243 | { | 
|  | 6244 | if (__result_ == nullptr && __x.__result_ == nullptr) | 
|  | 6245 | return true; | 
|  | 6246 | if (__result_ == &__suffix_ && __x.__result_ == &__x.__suffix_ && | 
|  | 6247 | __suffix_ == __x.__suffix_) | 
|  | 6248 | return true; | 
|  | 6249 | if (__result_ == nullptr || __x.__result_ == nullptr) | 
|  | 6250 | return false; | 
|  | 6251 | if (__result_ == &__suffix_ || __x.__result_ == &__x.__suffix_) | 
|  | 6252 | return false; | 
|  | 6253 | return __position_ == __x.__position_ && _N_ == __x._N_ && | 
|  | 6254 | __subs_ == __x.__subs_; | 
|  | 6255 | } | 
|  | 6256 |  | 
|  | 6257 | template <class _BidirectionalIterator, class _CharT, class _Traits> | 
|  | 6258 | regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>& | 
|  | 6259 | regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::operator++() | 
|  | 6260 | { | 
|  | 6261 | _Position __prev = __position_; | 
|  | 6262 | if (__result_ == &__suffix_) | 
|  | 6263 | __result_ = nullptr; | 
|  | 6264 | else if (_N_ + 1 < __subs_.size()) | 
|  | 6265 | { | 
|  | 6266 | ++_N_; | 
|  | 6267 | if (__subs_[_N_] == -1) | 
|  | 6268 | __result_ = &__position_->prefix(); | 
|  | 6269 | else | 
|  | 6270 | __result_ = &(*__position_)[__subs_[_N_]]; | 
|  | 6271 | } | 
|  | 6272 | else | 
|  | 6273 | { | 
|  | 6274 | _N_ = 0; | 
|  | 6275 | ++__position_; | 
|  | 6276 | if (__position_ != _Position()) | 
|  | 6277 | { | 
|  | 6278 | if (__subs_[_N_] == -1) | 
|  | 6279 | __result_ = &__position_->prefix(); | 
|  | 6280 | else | 
|  | 6281 | __result_ = &(*__position_)[__subs_[_N_]]; | 
|  | 6282 | } | 
|  | 6283 | else | 
|  | 6284 | { | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 6285 | if (_VSTD::find(__subs_.begin(), __subs_.end(), -1) != __subs_.end() | 
| Howard Hinnant | 262b779 | 2010-08-17 20:42:03 | [diff] [blame] | 6286 | && __prev->suffix().length() != 0) | 
|  | 6287 | { | 
|  | 6288 | __suffix_.matched = true; | 
|  | 6289 | __suffix_.first = __prev->suffix().first; | 
|  | 6290 | __suffix_.second = __prev->suffix().second; | 
|  | 6291 | __result_ = &__suffix_; | 
|  | 6292 | } | 
|  | 6293 | else | 
|  | 6294 | __result_ = nullptr; | 
|  | 6295 | } | 
|  | 6296 | } | 
|  | 6297 | return *this; | 
|  | 6298 | } | 
|  | 6299 |  | 
| Howard Hinnant | a712c72 | 2010-08-16 20:21:16 | [diff] [blame] | 6300 | typedef regex_token_iterator<const char*> cregex_token_iterator; | 
|  | 6301 | typedef regex_token_iterator<const wchar_t*> wcregex_token_iterator; | 
|  | 6302 | typedef regex_token_iterator<string::const_iterator> sregex_token_iterator; | 
|  | 6303 | typedef regex_token_iterator<wstring::const_iterator> wsregex_token_iterator; | 
|  | 6304 |  | 
| Howard Hinnant | a8d7759 | 2010-08-18 00:13:08 | [diff] [blame] | 6305 | // regex_replace | 
|  | 6306 |  | 
|  | 6307 | template <class _OutputIterator, class _BidirectionalIterator, | 
|  | 6308 | class _Traits, class _CharT> | 
|  | 6309 | _OutputIterator | 
|  | 6310 | regex_replace(_OutputIterator __out, | 
|  | 6311 | _BidirectionalIterator __first, _BidirectionalIterator __last, | 
|  | 6312 | const basic_regex<_CharT, _Traits>& __e, const _CharT* __fmt, | 
|  | 6313 | regex_constants::match_flag_type __flags = regex_constants::match_default) | 
|  | 6314 | { | 
|  | 6315 | typedef regex_iterator<_BidirectionalIterator, _CharT, _Traits> _Iter; | 
|  | 6316 | _Iter __i(__first, __last, __e, __flags); | 
|  | 6317 | _Iter __eof; | 
|  | 6318 | if (__i == __eof) | 
|  | 6319 | { | 
|  | 6320 | if (!(__flags & regex_constants::format_no_copy)) | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 6321 | __out = _VSTD::copy(__first, __last, __out); | 
| Howard Hinnant | a8d7759 | 2010-08-18 00:13:08 | [diff] [blame] | 6322 | } | 
|  | 6323 | else | 
|  | 6324 | { | 
|  | 6325 | sub_match<_BidirectionalIterator> __lm; | 
|  | 6326 | for (size_t __len = char_traits<_CharT>::length(__fmt); __i != __eof; ++__i) | 
|  | 6327 | { | 
|  | 6328 | if (!(__flags & regex_constants::format_no_copy)) | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 6329 | __out = _VSTD::copy(__i->prefix().first, __i->prefix().second, __out); | 
| Howard Hinnant | a8d7759 | 2010-08-18 00:13:08 | [diff] [blame] | 6330 | __out = __i->format(__out, __fmt, __fmt + __len, __flags); | 
|  | 6331 | __lm = __i->suffix(); | 
|  | 6332 | if (__flags & regex_constants::format_first_only) | 
|  | 6333 | break; | 
|  | 6334 | } | 
|  | 6335 | if (!(__flags & regex_constants::format_no_copy)) | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 6336 | __out = _VSTD::copy(__lm.first, __lm.second, __out); | 
| Howard Hinnant | a8d7759 | 2010-08-18 00:13:08 | [diff] [blame] | 6337 | } | 
|  | 6338 | return __out; | 
|  | 6339 | } | 
|  | 6340 |  | 
|  | 6341 | template <class _OutputIterator, class _BidirectionalIterator, | 
|  | 6342 | class _Traits, class _CharT, class _ST, class _SA> | 
|  | 6343 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 6344 | _OutputIterator | 
|  | 6345 | regex_replace(_OutputIterator __out, | 
|  | 6346 | _BidirectionalIterator __first, _BidirectionalIterator __last, | 
|  | 6347 | const basic_regex<_CharT, _Traits>& __e, | 
|  | 6348 | const basic_string<_CharT, _ST, _SA>& __fmt, | 
|  | 6349 | regex_constants::match_flag_type __flags = regex_constants::match_default) | 
|  | 6350 | { | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 6351 | return _VSTD::regex_replace(__out, __first, __last, __e, __fmt.c_str(), __flags); | 
| Howard Hinnant | a8d7759 | 2010-08-18 00:13:08 | [diff] [blame] | 6352 | } | 
|  | 6353 |  | 
|  | 6354 | template <class _Traits, class _CharT, class _ST, class _SA, class _FST, | 
|  | 6355 | class _FSA> | 
|  | 6356 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 6357 | basic_string<_CharT, _ST, _SA> | 
|  | 6358 | regex_replace(const basic_string<_CharT, _ST, _SA>& __s, | 
|  | 6359 | const basic_regex<_CharT, _Traits>& __e, | 
|  | 6360 | const basic_string<_CharT, _FST, _FSA>& __fmt, | 
|  | 6361 | regex_constants::match_flag_type __flags = regex_constants::match_default) | 
|  | 6362 | { | 
|  | 6363 | basic_string<_CharT, _ST, _SA> __r; | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 6364 | _VSTD::regex_replace(back_inserter(__r), __s.begin(), __s.end(), __e, | 
| Howard Hinnant | a8d7759 | 2010-08-18 00:13:08 | [diff] [blame] | 6365 | __fmt.c_str(), __flags); | 
|  | 6366 | return __r; | 
|  | 6367 | } | 
|  | 6368 |  | 
|  | 6369 | template <class _Traits, class _CharT, class _ST, class _SA> | 
|  | 6370 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 6371 | basic_string<_CharT, _ST, _SA> | 
|  | 6372 | regex_replace(const basic_string<_CharT, _ST, _SA>& __s, | 
|  | 6373 | const basic_regex<_CharT, _Traits>& __e, const _CharT* __fmt, | 
|  | 6374 | regex_constants::match_flag_type __flags = regex_constants::match_default) | 
|  | 6375 | { | 
|  | 6376 | basic_string<_CharT, _ST, _SA> __r; | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 6377 | _VSTD::regex_replace(back_inserter(__r), __s.begin(), __s.end(), __e, | 
| Howard Hinnant | a8d7759 | 2010-08-18 00:13:08 | [diff] [blame] | 6378 | __fmt, __flags); | 
|  | 6379 | return __r; | 
|  | 6380 | } | 
|  | 6381 |  | 
|  | 6382 | template <class _Traits, class _CharT, class _ST, class _SA> | 
|  | 6383 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 6384 | basic_string<_CharT> | 
|  | 6385 | regex_replace(const _CharT* __s, | 
|  | 6386 | const basic_regex<_CharT, _Traits>& __e, | 
|  | 6387 | const basic_string<_CharT, _ST, _SA>& __fmt, | 
|  | 6388 | regex_constants::match_flag_type __flags = regex_constants::match_default) | 
|  | 6389 | { | 
|  | 6390 | basic_string<_CharT> __r; | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 6391 | _VSTD::regex_replace(back_inserter(__r), __s, | 
| Howard Hinnant | a8d7759 | 2010-08-18 00:13:08 | [diff] [blame] | 6392 | __s + char_traits<_CharT>::length(__s), __e, | 
|  | 6393 | __fmt.c_str(), __flags); | 
|  | 6394 | return __r; | 
|  | 6395 | } | 
|  | 6396 |  | 
|  | 6397 | template <class _Traits, class _CharT> | 
|  | 6398 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 6399 | basic_string<_CharT> | 
|  | 6400 | regex_replace(const _CharT* __s, | 
|  | 6401 | const basic_regex<_CharT, _Traits>& __e, | 
|  | 6402 | const _CharT* __fmt, | 
|  | 6403 | regex_constants::match_flag_type __flags = regex_constants::match_default) | 
|  | 6404 | { | 
|  | 6405 | basic_string<_CharT> __r; | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 6406 | _VSTD::regex_replace(back_inserter(__r), __s, | 
| Howard Hinnant | a8d7759 | 2010-08-18 00:13:08 | [diff] [blame] | 6407 | __s + char_traits<_CharT>::length(__s), __e, | 
|  | 6408 | __fmt, __flags); | 
|  | 6409 | return __r; | 
|  | 6410 | } | 
|  | 6411 |  | 
| Howard Hinnant | 3257c98 | 2010-06-17 00:34:59 | [diff] [blame] | 6412 | _LIBCPP_END_NAMESPACE_STD | 
|  | 6413 |  | 
|  | 6414 | #endif // _LIBCPP_REGEX |